v-delete-sys-quota 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # info: delete system quota
  3. # opions: NONE
  4. #
  5. # The script disables filesystem quota on /home patition
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Includes
  10. source $VESTA/func/main.sh
  11. source $VESTA/conf/vesta.conf
  12. #----------------------------------------------------------#
  13. # Verifications #
  14. #----------------------------------------------------------#
  15. #----------------------------------------------------------#
  16. # Action #
  17. #----------------------------------------------------------#
  18. # Deleting usrquota on /home partition
  19. mnt=$(df -P /home |awk '{print $6}' |tail -n1)
  20. lnr=$(cat -n /etc/fstab |awk '{print $1,$3}' |grep "$mnt$" |cut -f 1 -d ' ')
  21. options=$(sed -n ${lnr}p /etc/fstab |awk '{print $4}')
  22. if [ ! -z "$(echo $options |grep usrquota)" ]; then
  23. sed -i "$lnr s/,usrquota//" /etc/fstab
  24. mount -o remount $mnt
  25. fi
  26. # Disabling fs quota
  27. if [ -z "$(quotaon -pa|grep " $mnt "|grep user|grep 'off')" ]; then
  28. quotaoff $mnt
  29. fi
  30. # Deleting quota index
  31. if [ -e "$mnt/aquota.user" ]; then
  32. rm $mnt/aquota.user
  33. fi
  34. # Deleting weekly cron job
  35. rm -f /etc/cron.daily/quotacheck
  36. # Updating DISK_QUOTA value
  37. if [ -z "$(grep DISK_QUOTA $VESTA/conf/vesta.conf)" ]; then
  38. echo "DISK_QUOTA='no'" >> $VESTA/conf/vesta.conf
  39. else
  40. sed -i "s/DISK_QUOTA=.*/DISK_QUOTA='no'/g" $VESTA/conf/vesta.conf
  41. fi
  42. #----------------------------------------------------------#
  43. # Vesta #
  44. #----------------------------------------------------------#
  45. # Logging
  46. log_event "$OK" "$EVENT"
  47. exit