mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
Merge pull request #150 from TechExhibeo/1.8.0
add a check for openvz containers for tmp.mount
This commit is contained in:
@@ -136,55 +136,68 @@ class preFlightsChecks:
|
|||||||
|
|
||||||
def mountTemp(self):
|
def mountTemp(self):
|
||||||
try:
|
try:
|
||||||
command = "dd if=/dev/zero of=/usr/.tempdisk bs=100M count=15"
|
## On OpenVZ there is an issue using .tempdisk for /tmp as it breaks network on container after reboot.
|
||||||
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
|
||||||
'mountTemp',
|
|
||||||
1, 0, os.EX_OSERR)
|
|
||||||
|
|
||||||
command = "mkfs.ext4 -F /usr/.tempdisk"
|
if subprocess.check_output('systemd-detect-virt').find("openvz") > -1:
|
||||||
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
|
||||||
'mountTemp',
|
|
||||||
1, 0, os.EX_OSERR)
|
|
||||||
|
|
||||||
command = "mkdir -p /usr/.tmpbak/"
|
varTmp = "/var/tmp /tmp none bind 0 0\n"
|
||||||
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
|
||||||
'mountTemp',
|
|
||||||
1, 0, os.EX_OSERR)
|
|
||||||
|
|
||||||
command = "cp -pr /tmp/* /usr/.tmpbak/"
|
fstab = "/etc/fstab"
|
||||||
subprocess.call(command, shell=True)
|
writeToFile = open(fstab, "a")
|
||||||
|
writeToFile.writelines(varTmp)
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
command = "mount -o loop,rw,nodev,nosuid,noexec,nofail /usr/.tempdisk /tmp"
|
else:
|
||||||
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
|
||||||
'mountTemp',
|
|
||||||
1, 0, os.EX_OSERR)
|
|
||||||
|
|
||||||
command = "chmod 1777 /tmp"
|
command = "dd if=/dev/zero of=/usr/.tempdisk bs=100M count=15"
|
||||||
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
||||||
'mountTemp',
|
'mountTemp',
|
||||||
1, 0, os.EX_OSERR)
|
1, 0, os.EX_OSERR)
|
||||||
|
|
||||||
command = "cp -pr /usr/.tmpbak/* /tmp/"
|
command = "mkfs.ext4 -F /usr/.tempdisk"
|
||||||
subprocess.call(command, shell=True)
|
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
||||||
|
'mountTemp',
|
||||||
|
1, 0, os.EX_OSERR)
|
||||||
|
|
||||||
command = "rm -rf /usr/.tmpbak"
|
command = "mkdir -p /usr/.tmpbak/"
|
||||||
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
||||||
'mountTemp',
|
'mountTemp',
|
||||||
1, 0, os.EX_OSERR)
|
1, 0, os.EX_OSERR)
|
||||||
|
|
||||||
command = "mount --bind /tmp /var/tmp"
|
command = "cp -pr /tmp/* /usr/.tmpbak/"
|
||||||
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
subprocess.call(command, shell=True)
|
||||||
'mountTemp',
|
|
||||||
1, 0, os.EX_OSERR)
|
|
||||||
|
|
||||||
tmp = "/usr/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0\n"
|
command = "mount -o loop,rw,nodev,nosuid,noexec,nofail /usr/.tempdisk /tmp"
|
||||||
varTmp = "/tmp /var/tmp none bind 0 0\n"
|
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
||||||
|
'mountTemp',
|
||||||
|
1, 0, os.EX_OSERR)
|
||||||
|
|
||||||
fstab = "/etc/fstab"
|
command = "chmod 1777 /tmp"
|
||||||
writeToFile = open(fstab, "a")
|
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
||||||
writeToFile.writelines(tmp)
|
'mountTemp',
|
||||||
writeToFile.writelines(varTmp)
|
1, 0, os.EX_OSERR)
|
||||||
writeToFile.close()
|
|
||||||
|
command = "cp -pr /usr/.tmpbak/* /tmp/"
|
||||||
|
subprocess.call(command, shell=True)
|
||||||
|
|
||||||
|
command = "rm -rf /usr/.tmpbak"
|
||||||
|
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
||||||
|
'mountTemp',
|
||||||
|
1, 0, os.EX_OSERR)
|
||||||
|
|
||||||
|
command = "mount --bind /tmp /var/tmp"
|
||||||
|
preFlightsChecks.call(command, self.distro, '[mountTemp]',
|
||||||
|
'mountTemp',
|
||||||
|
1, 0, os.EX_OSERR)
|
||||||
|
|
||||||
|
tmp = "/usr/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0\n"
|
||||||
|
varTmp = "/tmp /var/tmp none bind 0 0\n"
|
||||||
|
|
||||||
|
fstab = "/etc/fstab"
|
||||||
|
writeToFile = open(fstab, "a")
|
||||||
|
writeToFile.writelines(tmp)
|
||||||
|
writeToFile.writelines(varTmp)
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
preFlightsChecks.stdOut("[Failed:mountTemp] " + str(msg))
|
preFlightsChecks.stdOut("[Failed:mountTemp] " + str(msg))
|
||||||
|
|||||||
Reference in New Issue
Block a user