v-delete-sys-quota 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. # info: delete system quota
  3. # options: NONE
  4. #
  5. # The script disables filesystem quota on /home partition
  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 group and user quota 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. opt=$(sed -n ${lnr}p /etc/fstab | awk '{print $4}')
  22. fnd='usrquota\|grpquota\|usrjquota=\|grpjquota=\|jqfmt='
  23. if [ ! -z "$(echo $opt | grep $fnd)" ]; then
  24. rep=$(echo $(echo $opt | tr ',' '\n' | grep -v $fnd) | tr ' ' ',')
  25. sed -i "$lnr s/$opt/$rep/" /etc/fstab
  26. mount -o remount $mnt
  27. fi
  28. # Disabling group and user quota
  29. quotaoff=$(which --skip-alias --skip-functions quotaoff 2>/dev/null)
  30. if [ $? -eq 0 ]; then
  31. if [ ! -z "$(quotaon -pa | grep " $mnt " | grep 'user\|group' | grep 'is on')" ]; then
  32. $quotaoff $mnt
  33. fi
  34. fi
  35. # Deleting v1 + v2 group and user quota index
  36. for idx in $(echo 'quota.user quota.group aquota.user aquota.group'); do
  37. [ -e "$mnt/$idx" ] && rm -f $mnt/$idx
  38. done
  39. # Deleting cron job
  40. rm -f /etc/cron.daily/quotacheck
  41. # Updating vesta.conf value
  42. if [ -z "$(grep DISK_QUOTA $VESTA/conf/vesta.conf)" ]; then
  43. echo "DISK_QUOTA='no'" >> $VESTA/conf/vesta.conf
  44. else
  45. sed -i "s/DISK_QUOTA=.*/DISK_QUOTA='no'/g" $VESTA/conf/vesta.conf
  46. fi
  47. #----------------------------------------------------------#
  48. # Vesta #
  49. #----------------------------------------------------------#
  50. # Logging
  51. log_event "$OK" "$ARGUMENTS"
  52. exit