From 83ee98e81e8d162a0cad16c9c7287f797865c617 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Wed, 18 Sep 2024 15:13:11 +0500 Subject: [PATCH] quotas for xfs --- install/install.py | 14 -------------- plogical/upgrade.py | 30 +++++++++++------------------- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/install/install.py b/install/install.py index de4a66dd2..fd3c13025 100755 --- a/install/install.py +++ b/install/install.py @@ -277,13 +277,6 @@ def edit_fstab(self,mount_point, options_to_add): try: if parts[1] == '/' and parts[3].find('usrquota,grpquota') == -1 and len(parts[3]) > 4: - ### if xfx dont move forward for now - if line.find('xfs') > -1: - retValue = 0 - WriteToFile.write(line) - continue - ### - parts[3] = f'{parts[3]},usrquota,grpquota' finalString = '\t'.join(parts) print(finalString) @@ -291,13 +284,6 @@ def edit_fstab(self,mount_point, options_to_add): elif parts[1] == '/': - ### if xfx dont move forward for now - if line.find('xfs') > -1: - retValue = 0 - WriteToFile.write(line) - continue - ### - for ii, p in enumerate(parts): if p.find('defaults') > -1 or p.find('discard') > -1: parts[ii] = f'{parts[ii]},usrquota,grpquota' diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 7c4eeb369..54447f587 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -3629,13 +3629,19 @@ def installQuota(): @staticmethod def edit_fstab(mount_point, options_to_add): - try: retValue = 1 # Backup the original fstab file fstab_path = '/etc/fstab' backup_path = fstab_path + '.bak' + rData = open(fstab_path, 'r').read() + + if rData.find('xfs') > -1: + options_to_add = 'uquota' + else: + options_to_add = 'usrquota,grpquota' + if not os.path.exists(backup_path): shutil.copy(fstab_path, backup_path) @@ -3654,32 +3660,18 @@ def edit_fstab(mount_point, options_to_add): print(parts) try: - if parts[1] == '/' and parts[3].find('usrquota,grpquota') == -1 and len(parts[3]) > 4: + if parts[1] == '/' and parts[3].find(options_to_add) == -1 and len(parts[3]) > 4: - ### if xfx dont move forward for now - if line.find('xfs') > -1: - retValue = 0 - WriteToFile.write(line) - continue - ### - - parts[3] = f'{parts[3]},usrquota,grpquota' + parts[3] = f'{parts[3]},{options_to_add}' finalString = '\t'.join(parts) print(finalString) WriteToFile.write(finalString) elif parts[1] == '/': - ### if xfx dont move forward for now - if line.find('xfs') > -1: - retValue = 0 - WriteToFile.write(line) - continue - ### - for ii, p in enumerate(parts): if p.find('defaults') > -1 or p.find('discard') > -1: - parts[ii] = f'{parts[ii]},usrquota,grpquota' + parts[ii] = f'{parts[ii]},{options_to_add}' finalString = '\t'.join(parts) print(finalString) WriteToFile.write(finalString) @@ -3701,7 +3693,7 @@ def FixCurrentQuoatasSystem(): data = open(fstab_path, 'r').read() - if data.find("usrquota,grpquota") > -1: + if data.find("usrquota,grpquota") > -1 or data.find("uquota") > -1: print("Quotas already enabled.")