vesta/bin/v_upd_web_domain_disk
2011-06-30 01:00:27 +03:00

70 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# info: updating disk usage for domain
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user="$1"
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared_func.sh
source $V_FUNC/domain_func.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'web'
# Checking user
is_user_valid
# Checking domain exist
is_web_domain_valid
# Checking domain is not suspened
is_domain_suspended 'web_domains'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining home directory
home_dir="$V_HOME/$user/domains/$domain/"
# Checking home directory exist
if [ -e "$home_dir" ]; then
disk_usage=$(nice -n 19 du -shm $home_dir | cut -f 1 )
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Updating disk value in config
update_web_domain_value '$U_DISK' "$disk_usage"
# Recalculating user disk space
disk_size=$(get_usr_disk)
update_user_value "$user" '$U_DISK' "$disk_size"
# Logging
log_event 'system' "$V_EVENT"
exit $OK