myvesta/bin/v-update-database-disk
2013-10-09 00:50:08 +03:00

61 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# info: update database disk usage
# options: USER DATABASE
#
# The function recalculates disk usage for speciefic database.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
database=$2
# Includes
source $VESTA/func/main.sh
source $VESTA/func/db.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'USER DATABASE'
validate_format 'user' 'database'
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'db' 'DB' "$database"
is_object_unsuspended 'db' 'DB' "$database"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get database values
get_database_values
# Switching on db type
case $TYPE in
mysql) get_mysql_disk_usage ;;
pgsql) get_pgsql_disk_usage ;;
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Updating disk usage
update_object_value 'db' 'DB' "$database" '$U_DISK' "$usage"
recalc_user_disk_usage
# Logging
log_event "$OK" "$EVENT"
exit