mirror of
https://github.com/myvesta/vesta.git
synced 2024-11-03 04:00:20 -08:00
58 lines
1.5 KiB
Bash
Executable File
58 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: update user disk quota
|
|
# options: USER
|
|
#
|
|
# The functions upates disk quota for specific user
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
user=$1
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '1' "$#" 'USER'
|
|
is_format_valid 'user'
|
|
is_object_valid 'user' 'USER' "$user"
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Updating disk quota
|
|
# Had quota equals package value. Soft quota equals 90% of package value for warnings.
|
|
quota=$(get_user_value '$DISK_QUOTA')
|
|
soft=$(echo "$quota * 1024"|bc |cut -f 1 -d .)
|
|
hard=$(echo "$quota * 1024"|bc |cut -f 1 -d .)
|
|
|
|
# Searching home mount point
|
|
mnt=$(df -P /home |awk '{print $6}' |tail -n1)
|
|
|
|
# Checking unlinmited quota
|
|
if [ "$quota" = 'unlimited' ]; then
|
|
setquota $user 0 0 0 0 $mnt 2>/dev/null
|
|
else
|
|
setquota $user $soft $hard 0 0 $mnt 2>/dev/null
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Logging
|
|
log_event "$OK" "$ARGUMENTS"
|
|
|
|
exit
|