From 5f0bbf718a6268f81c3f57e9de83154505ce1883 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Fri, 20 Sep 2024 21:44:56 +0500 Subject: [PATCH] bug fix: contabo on quotas --- plogical/upgrade.py | 57 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 38f0783c2..38e5d5f5b 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -3544,11 +3544,11 @@ def installQuota(): print("Re-mount failed, restoring original FSTab and existing quota setup.") return 0 - ## if Upgrade.FindOperatingSytem() == Ubuntu22 or Upgrade.FindOperatingSytem() == Ubuntu18 \ or Upgrade.FindOperatingSytem() == Ubuntu20: + print("Install Quota on Ubuntu") command = 'apt update -y' Upgrade.executioner(command, command, 0, True) @@ -3580,7 +3580,16 @@ def installQuota(): return 0 command = 'quotacheck -ugm /' - Upgrade.executioner(command, command, 0, True) + mResult = subprocess.run(command, capture_output=True, text=True, shell=True) + if mResult.returncode != 0: + fstab_path = '/etc/fstab' + backup_path = fstab_path + '.bak' + if os.path.exists(fstab_path): + os.remove(fstab_path) + shutil.copy(backup_path, fstab_path) + + print("Re-mount failed, restoring original FSTab and existing quota setup.") + return 0 #### @@ -3606,16 +3615,52 @@ def installQuota(): ### command = f'modprobe quota_v1 -S {ffResult}' - Upgrade.executioner(command, command, 0, True) + mResult = subprocess.run(command, capture_output=True, text=True, shell=True) + if mResult.returncode != 0: + fstab_path = '/etc/fstab' + backup_path = fstab_path + '.bak' + if os.path.exists(fstab_path): + os.remove(fstab_path) + shutil.copy(backup_path, fstab_path) + + print("Re-mount failed, restoring original FSTab and existing quota setup.") + return 0 command = f'modprobe quota_v2 -S {ffResult}' - Upgrade.executioner(command, command, 0, True) + mResult = subprocess.run(command, capture_output=True, text=True, shell=True) + if mResult.returncode != 0: + fstab_path = '/etc/fstab' + backup_path = fstab_path + '.bak' + if os.path.exists(fstab_path): + os.remove(fstab_path) + shutil.copy(backup_path, fstab_path) + + print("Re-mount failed, restoring original FSTab and existing quota setup.") + return 0 command = f'quotacheck -ugm /' - Upgrade.executioner(command, command, 0, True) + mResult = subprocess.run(command, capture_output=True, text=True, shell=True) + if mResult.returncode != 0: + fstab_path = '/etc/fstab' + backup_path = fstab_path + '.bak' + if os.path.exists(fstab_path): + os.remove(fstab_path) + shutil.copy(backup_path, fstab_path) + + print("Re-mount failed, restoring original FSTab and existing quota setup.") + return 0 command = f'quotaon -v /' - Upgrade.executioner(command, command, 0, True) + mResult = subprocess.run(command, capture_output=True, text=True, shell=True) + if mResult.returncode != 0: + fstab_path = '/etc/fstab' + backup_path = fstab_path + '.bak' + if os.path.exists(fstab_path): + os.remove(fstab_path) + shutil.copy(backup_path, fstab_path) + + print("Re-mount failed, restoring original FSTab and existing quota setup.") + return 0 return 1