Skip to content

Commit

Permalink
quotas for xfs
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Sep 18, 2024
1 parent 83ee98e commit 2df62ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 14 additions & 5 deletions install/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -275,19 +282,21 @@ 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)

elif parts[1] == '/':

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:
Expand Down
6 changes: 4 additions & 2 deletions plogical/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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:
Expand Down

0 comments on commit 2df62ef

Please sign in to comment.