From 2df62efd849f99aa7161ae6967c1b4a37c2cf136 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Wed, 18 Sep 2024 15:35:07 +0500 Subject: [PATCH] quotas for xfs --- install/install.py | 19 ++++++++++++++----- plogical/upgrade.py | 6 ++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/install/install.py b/install/install.py index fd3c13025..b3603010e 100755 --- a/install/install.py +++ b/install/install.py @@ -257,6 +257,13 @@ def edit_fstab(self,mount_point, options_to_add): 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) @@ -275,10 +282,11 @@ def edit_fstab(self,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: - parts[3] = f'{parts[3]},usrquota,grpquota' - finalString = '\t'.join(parts) + parts[3] = f'{parts[3]},{options_to_add}' + tempParts = [item for item in parts if item.strip()] + finalString = '\t'.join(tempParts) print(finalString) WriteToFile.write(finalString) @@ -286,8 +294,9 @@ def edit_fstab(self,mount_point, options_to_add): for ii, p in enumerate(parts): if p.find('defaults') > -1 or p.find('discard') > -1: - parts[ii] = f'{parts[ii]},usrquota,grpquota' - finalString = '\t'.join(parts) + parts[ii] = f'{parts[ii]},{options_to_add}' + tempParts = [item for item in parts if item.strip()] + finalString = '\t'.join(tempParts) print(finalString) WriteToFile.write(finalString) else: diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 54447f587..162fc6730 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -3663,7 +3663,8 @@ def edit_fstab(mount_point, options_to_add): if parts[1] == '/' and parts[3].find(options_to_add) == -1 and len(parts[3]) > 4: parts[3] = f'{parts[3]},{options_to_add}' - finalString = '\t'.join(parts) + tempParts = [item for item in parts if item.strip()] + finalString = '\t'.join(tempParts) print(finalString) WriteToFile.write(finalString) @@ -3672,7 +3673,8 @@ def edit_fstab(mount_point, options_to_add): for ii, p in enumerate(parts): if p.find('defaults') > -1 or p.find('discard') > -1: parts[ii] = f'{parts[ii]},{options_to_add}' - finalString = '\t'.join(parts) + tempParts = [item for item in parts if item.strip()] + finalString = '\t'.join(tempParts) print(finalString) WriteToFile.write(finalString) else: