mirror of
https://github.com/serghey-rodin/vesta.git
synced 2024-12-03 19:00:24 -08:00
69 lines
2.1 KiB
Bash
Executable File
69 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: delete system quota
|
|
# options: NONE
|
|
#
|
|
# The script disables filesystem quota on /home partition
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable & Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Deleting group and user quota on /home partition
|
|
mnt=$(df -P /home | awk '{print $6}' | tail -n1)
|
|
lnr=$(cat -n /etc/fstab | awk '{print $1,$3}' | grep "$mnt$" | cut -f 1 -d ' ')
|
|
opt=$(sed -n ${lnr}p /etc/fstab | awk '{print $4}')
|
|
fnd='usrquota\|grpquota\|usrjquota=\|grpjquota=\|jqfmt='
|
|
if [ ! -z "$(echo $opt | grep $fnd)" ]; then
|
|
rep=$(echo $(echo $opt | tr ',' '\n' | grep -v $fnd) | tr ' ' ',')
|
|
sed -i "$lnr s/$opt/$rep/" /etc/fstab
|
|
mount -o remount $mnt
|
|
fi
|
|
|
|
# Disabling group and user quota
|
|
quotaoff=$(which --skip-alias --skip-functions quotaoff 2>/dev/null)
|
|
if [ $? -eq 0 ]; then
|
|
if [ ! -z "$(quotaon -pa | grep " $mnt " | grep 'user\|group' | grep 'is on')" ]; then
|
|
$quotaoff $mnt
|
|
fi
|
|
fi
|
|
|
|
# Deleting v1 + v2 group and user quota index
|
|
for idx in $(echo 'quota.user quota.group aquota.user aquota.group'); do
|
|
[ -e "$mnt/$idx" ] && rm -f $mnt/$idx
|
|
done
|
|
|
|
# Deleting cron job
|
|
rm -f /etc/cron.daily/quotacheck
|
|
|
|
# Updating vesta.conf value
|
|
if [ -z "$(grep DISK_QUOTA $VESTA/conf/vesta.conf)" ]; then
|
|
echo "DISK_QUOTA='no'" >> $VESTA/conf/vesta.conf
|
|
else
|
|
sed -i "s/DISK_QUOTA=.*/DISK_QUOTA='no'/g" $VESTA/conf/vesta.conf
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Logging
|
|
log_event "$OK" "$ARGUMENTS"
|
|
|
|
exit
|