@@ -47,20 +47,47 @@ check_hestia_demo_mode
4747
4848# Adding group and user quota on /home partition
4949mnt=$( df -P /home | awk ' {print $6}' | tail -n1)
50+ fs_type=$( df -T " $mnt " | awk ' {print $2}' | tail -n1)
5051lnr=$( cat -n /etc/fstab | grep -v " #" | awk ' {print $1,$3}' | grep " $mnt $" | cut -f 1 -d ' ' )
5152opt=$( sed -n ${lnr} p /etc/fstab | awk ' {print $4}' )
52- fnd=' usrquota\|grpquota\|usrjquota=aquota.user\|grpjquota=aquota.group\|jqfmt=vfsv0'
53- if [ " $( echo " $opt " | tr ' ,' ' \n' | grep -c -x $fnd ) " -ne 5 ]; then
54- old=$( echo $( echo $opt | tr ' ,' ' \n' | grep -v ' usrquota\|grpquota\|usrjquota=\|grpjquota=\|jqfmt=' ) | tr ' ' ' ,' )
53+
54+ if [[ " $fs_type " == " xfs" ]]; then
55+ log_history " XFS filesystem detected on $mnt . Modifying GRUB for XFS quota."
56+ grub_conf=" /etc/default/grub"
57+
58+ if ! grep -q " rootflags=.*uquota" " $grub_conf " || ! grep -q " systemd.unified_cgroup_hierarchy=1" " $grub_conf " ; then
59+ params=" rootflags=uquota,pquota,gquota systemd.unified_cgroup_hierarchy=1"
60+ sed -i ' s/^\(GRUB_CMDLINE_LINUX="[^"]*\)/\1 ' " $params " ' /' " $grub_conf "
61+ check_result $? " Failed to add kernel parameters to $grub_conf "
62+ update-grub > /dev/null 2>&1
63+ log_history " GRUB updated. A system reboot is required to apply changes."
64+ reboot_req=" Y"
65+ else
66+ log_history " XFS quota flags already present in GRUB configuration."
67+ fi
68+ else
69+ # >> Non XFS Filesystem
70+ log_history " $fs_type filesystem on $mnt . Using standard quota parameters."
71+ fnd=' usrquota\|grpquota\|usrjquota=aquota.user\|grpjquota=aquota.group\|jqfmt=vfsv0'
5572 new=' usrquota,grpquota,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0'
56- sed -i " $lnr s/$opt /$old ,$new /" /etc/fstab
57- systemctl daemon-reload
58- mount -o remount " $mnt "
73+
74+ # >> Modify /etc/fstab
75+ if [ " $( echo " $opt " | tr ' ,' ' \n' | grep -c -xE " $fnd " ) " -ne " $( echo " $fnd " | tr ' \|' ' \n' | wc -l) " ]; then
76+ old=$( echo " $opt " | tr ' ,' ' \n' | grep -vE ' usrquota|grpquota|usrjquota=|grpjquota=|jqfmt=|uquota|gquota' | tr ' \n' ' ,' | sed ' s/,$//' )
77+ if [ -n " $old " ]; then
78+ sed -i " $lnr s/$opt /$old ,$new /" /etc/fstab
79+ fi
80+ systemctl daemon-reload
81+ mount -o remount " $mnt "
82+ fi
5983fi
6084
61- # Adding v2 group and user quota index
62- if [ ! -e " $mnt /aquota.user" ] || [ ! -e " $mnt /aquota.group" ]; then
63- quotacheck -avcugm > /dev/null 2>&1
85+ # >> Adding v2 group and user quota index
86+ # >> For XFS, aquota files are not typically used, quota is managed directly within filesystem.
87+ if [ " $fs_type " != " xfs" ]; then
88+ if [ ! -e " $mnt /aquota.user" ] || [ ! -e " $mnt /aquota.group" ]; then
89+ quotacheck -avcugm > /dev/null 2>&1
90+ fi
6491fi
6592
6693# Adding quotacheck on reboot
@@ -94,4 +121,9 @@ $BIN/v-log-action "system" "Info" "Plugins" "System Quota enforcement enabled."
94121log_history " system quota enforcement enabled"
95122log_event " $OK " " $ARGUMENTS "
96123
124+ if [ " $reboot_req " = " Y" ]; then
125+ log_history " A system reboot is required to complete enable quota."
126+ echo " Warning: A system reboot is required to complete enable quota."
127+ fi
128+
97129exit
0 commit comments