diff --git a/install.sh b/install.sh index b8224b1e..f9c0e843 100644 --- a/install.sh +++ b/install.sh @@ -1136,36 +1136,43 @@ install_packages() { edit_fstab() { - -echo "Setting quotas for disk limits of user files" -fstab_file="/etc/fstab" -root_entry=$(grep -E '^\S+\s+/.*' "$fstab_file") - -if [[ "$root_entry" =~ "usrquota" && "$root_entry" =~ "grpquota" ]]; then - echo "Success, usrquota and grpquota are already set for /" -else - # Add usrquota and grpquota to the fstab entry (only for the root entry) - sudo sed -i 's|^\(LABEL=cloudimg-rootfs\s*/\s*ext4\s*[^,]*\)|\1,usrquota,grpquota|' "$fstab_file" - - echo "Success, usrquota and grpquota have been added to / entry in fstab, remounting.." -fi - systemctl daemon-reload + echo "Setting quotas for disk limits of user files" + fstab_file="/etc/fstab" + backup_file="/etc/fstab.bak" + + # Backup the original fstab file + cp "$fstab_file" "$backup_file" + + # Check if usrquota and grpquota are already set + if grep -qE '^[^#]\S+\s+/\s+\S+\s+.*usrquota.*grpquota' "$fstab_file"; then + echo "Success, usrquota and grpquota are already set for /" + else + echo "Adding usrquota and grpquota to / entry in fstab..." + + # Modify the / entry to include usrquota,grpquota correctly + sed -i -E '/\s+\/\s+/s/(\S+)(\s+\/\s+\S+\s+\S+)(\s+[0-9]+\s+[0-9]+)$/\1\2,usrquota,grpquota\3/' "$fstab_file" + + echo "Success, usrquota and grpquota have been added to / entry in fstab, remounting.." + fi + + # Apply changes + systemctl daemon-reload quotaoff -a mount -o remount,usrquota,grpquota / - mount /dev/vda1 /mnt - cd /mnt - chmod 600 aquota.user aquota.group + + # Ensure quota files exist + touch /aquota.user /aquota.group + chmod 600 /aquota.user /aquota.group quotacheck -cum / -f quotaon -a - repquota / - quota -v - echo "Testing quotas.." - repquota -u / > /etc/openpanel/openpanel/core/users/repquota - + # Generate quota report + repquota / > /etc/openpanel/openpanel/core/users/repquota + + echo "Testing quotas..." + quota -v } - set_system_cronjob(){ echo "Setting cronjobs.." mv ${ETC_DIR}cron /etc/cron.d/openpanel