vesta/bin/v_upd_web_domains_disk
2011-06-14 00:22:25 +03:00

78 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# info: updating disk usage for all user domains
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user="$1"
# 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 '1' "$#" 'user'
# Checking argument format
format_validation 'user'
# Checking web system is enabled
is_system_enabled 'web'
# Checking user
is_user_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
# Defining fileds to select
field='$DOMAIN'
# Defining search string
search_string="SUSPEND='no'"
# Parsing unsuspeneded domains
domains=$(dom_clear_search)
# Starting update disk loop
for domain in $domains; do
# 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
# Updating disk value in config
update_web_domain_value '$U_DISK' "$disk_usage"
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# 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