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 432a26d commit 83ee98e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 33 deletions.
14 changes: 0 additions & 14 deletions install/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,27 +277,13 @@ 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)
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'
Expand Down
30 changes: 11 additions & 19 deletions plogical/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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.")


Expand Down

0 comments on commit 83ee98e

Please sign in to comment.