mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-13 08:46:09 +01:00
added quoata install function
This commit is contained in:
@@ -179,12 +179,24 @@ class preFlightsChecks:
|
||||
command = 'quotacheck -ugm /'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
command = "find /lib/modules/ -type f -name '*quota_v*.ko*' | sed -n 's|/lib/modules/\([^/]*\)/.*|\1|p' | sort -u"
|
||||
####
|
||||
|
||||
result = subprocess.check_output(command, shell=True).decode("utf-8").rstrip('\n')
|
||||
command = "find /lib/modules/ -type f -name '*quota_v*.ko*'"
|
||||
iResult = subprocess.run(command, capture_output=True, text=True, shell=True)
|
||||
print(repr(iResult.stdout))
|
||||
|
||||
command = f"apt-get install linux-modules-extra-{result}"
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
# Only if the first command works, run the rest
|
||||
|
||||
if iResult.returncode == 0:
|
||||
command = "echo '{}' | sed -n 's|/lib/modules/\\([^/]*\\)/.*|\\1|p' | sort -u".format(iResult.stdout)
|
||||
result = subprocess.run(command, capture_output=True, text=True, shell=True)
|
||||
fResult = result.stdout.rstrip('\n')
|
||||
print(repr(result.stdout.rstrip('\n')))
|
||||
|
||||
command = f"apt-get install linux-modules-extra-{fResult}"
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
###
|
||||
|
||||
|
||||
command = f'modprobe quota_v1 -S {result}'
|
||||
|
||||
@@ -1042,24 +1042,27 @@ Automatic backup failed for %s on %s.
|
||||
"/home/" + website.domain, website.package.diskSpace)
|
||||
|
||||
if website.package.enforceDiskLimits:
|
||||
if config['DiskUsagePercentage'] >= 100:
|
||||
command = 'chattr -R +i /home/%s/' % (website.domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chattr -R -i /home/%s/logs/' % (website.domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chattr -R -i /home/%s/.trash/' % (website.domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chattr -R -i /home/%s/backup/' % (website.domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chattr -R -i /home/%s/incbackup/' % (website.domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
command = 'chattr -R -i /home/%s/' % (website.domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
spaceString = f'{website.package.diskSpace}M {website.package.diskSpace}M'
|
||||
command = f'setquota -u {website.externalApp} {spaceString} 0 0 /'
|
||||
ProcessUtilities.executioner(command)
|
||||
# if config['DiskUsagePercentage'] >= 100:
|
||||
# command = 'chattr -R +i /home/%s/' % (website.domain)
|
||||
# ProcessUtilities.executioner(command)
|
||||
#
|
||||
# command = 'chattr -R -i /home/%s/logs/' % (website.domain)
|
||||
# ProcessUtilities.executioner(command)
|
||||
#
|
||||
# command = 'chattr -R -i /home/%s/.trash/' % (website.domain)
|
||||
# ProcessUtilities.executioner(command)
|
||||
#
|
||||
# command = 'chattr -R -i /home/%s/backup/' % (website.domain)
|
||||
# ProcessUtilities.executioner(command)
|
||||
#
|
||||
# command = 'chattr -R -i /home/%s/incbackup/' % (website.domain)
|
||||
# ProcessUtilities.executioner(command)
|
||||
# else:
|
||||
# command = 'chattr -R -i /home/%s/' % (website.domain)
|
||||
# ProcessUtilities.executioner(command)
|
||||
|
||||
## Calculate bw usage
|
||||
|
||||
|
||||
@@ -38,14 +38,22 @@ def edit_fstab(mount_point, options_to_add):
|
||||
WriteToFile.write(line)
|
||||
WriteToFile.close()
|
||||
|
||||
command = "find /lib/modules/ -type f -name '*quota_v*.ko*'"
|
||||
print(command)
|
||||
|
||||
try:
|
||||
result = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT).decode("utf-8").rstrip('\n')
|
||||
print(repr(result))
|
||||
command = "find /lib/modules/ -type f -name '*quota_v*.ko*'"
|
||||
result = subprocess.run(command, capture_output=True, text=True, shell=True)
|
||||
print(repr(result.stdout))
|
||||
|
||||
# Only if the first command works, run the rest
|
||||
if result.returncode == 0:
|
||||
command = "echo '{}' | sed -n 's|/lib/modules/\\([^/]*\\)/.*|\\1|p' | sort -u".format(result.stdout)
|
||||
result = subprocess.run(command, capture_output=True, text=True, shell=True)
|
||||
print(repr(result.stdout.rstrip('\n')))
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("Error:", e.output.decode())
|
||||
|
||||
|
||||
edit_fstab('/', '/')
|
||||
|
||||
|
||||
|
||||
@@ -530,6 +530,13 @@ class virtualHostUtilities:
|
||||
|
||||
###
|
||||
|
||||
spaceString = f'{selectedPackage.diskSpace}M {selectedPackage.diskSpace}M'
|
||||
|
||||
if selectedPackage.enforceDiskLimits:
|
||||
command = f'setquota -u {virtualHostUser} {spaceString} 0 0 /'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Website successfully created. [200]')
|
||||
|
||||
return 1, 'None'
|
||||
|
||||
Reference in New Issue
Block a user