Skip to content

Commit 04f497d

Browse files
Update v-delete-sys-quota
- minor updates - see: v-add-sys-quota
1 parent bb037fa commit 04f497d

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

bin/v-delete-sys-quota

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/bash
22
# info: delete system quota
3-
# opions: NONE
3+
# options: NONE
44
#
55
# The script disables filesystem quota on /home patition
66

77

88
#----------------------------------------------------------#
9-
# Variable&Function #
9+
# Variable & Function #
1010
#----------------------------------------------------------#
1111

1212
# Includes
@@ -23,29 +23,34 @@ source $VESTA/conf/vesta.conf
2323
# Action #
2424
#----------------------------------------------------------#
2525

26-
# Deleting usrquota on /home partition
27-
mnt=$(df -P /home |awk '{print $6}' |tail -n1)
28-
lnr=$(cat -n /etc/fstab |awk '{print $1,$3}' |grep "$mnt$" |cut -f 1 -d ' ')
29-
options=$(sed -n ${lnr}p /etc/fstab |awk '{print $4}')
30-
if [ ! -z "$(echo $options |grep usrquota)" ]; then
31-
sed -i "$lnr s/,usrquota//" /etc/fstab
26+
# Deleting group and user quota on /home partition
27+
mnt=$(df -P /home | awk '{print $6}' | tail -n1)
28+
lnr=$(cat -n /etc/fstab | awk '{print $1,$3}' | grep "$mnt$" | cut -f 1 -d ' ')
29+
opt=$(sed -n ${lnr}p /etc/fstab | awk '{print $4}')
30+
fnd='usrquota\|grpquota\|usrjquota=\|grpjquota=\|jqfmt='
31+
if [ ! -z "$(echo $opt | grep $fnd)" ]; then
32+
rep=$(echo $(echo $opt | tr ',' '\n' | grep -v $fnd) | tr ' ' ',')
33+
sed -i "$lnr s/$opt/$rep/" /etc/fstab
3234
mount -o remount $mnt
3335
fi
3436

35-
# Disabling fs quota
36-
if [ -z "$(quotaon -pa|grep " $mnt "|grep user|grep 'off')" ]; then
37-
quotaoff $mnt
37+
# Disabling group and user quota
38+
quotaoff=$(which --skip-alias --skip-functions quotaoff 2>/dev/null)
39+
if [ $? -eq 0 ]; then
40+
if [ ! -z "$(quotaon -pa | grep " $mnt " | grep 'user\|group' | grep 'is on')" ]; then
41+
$quotaoff $mnt
42+
fi
3843
fi
3944

40-
# Deleting quota index
41-
if [ -e "$mnt/aquota.user" ]; then
42-
rm $mnt/aquota.user
43-
fi
45+
# Deleting v1 + v2 group and user quota index
46+
for idx in $(echo 'quota.user quota.group aquota.user aquota.group'); do
47+
[ -e "$mnt/$idx" ] && rm -f $mnt/$idx
48+
done
4449

45-
# Deleting weekly cron job
50+
# Deleting cron job
4651
rm -f /etc/cron.daily/quotacheck
4752

48-
# Updating DISK_QUOTA value
53+
# Updating vesta.conf value
4954
if [ -z "$(grep DISK_QUOTA $VESTA/conf/vesta.conf)" ]; then
5055
echo "DISK_QUOTA='no'" >> $VESTA/conf/vesta.conf
5156
else

0 commit comments

Comments
 (0)