mirror of
https://github.com/myvesta/vesta.git
synced 2024-11-20 20:40:08 -08:00
61 lines
1.6 KiB
Bash
Executable File
61 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: update database disk usage
|
|
# options: USER DATABASE
|
|
#
|
|
# The function recalculates disk usage for specific database.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
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'
|
|
is_format_valid '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" "$ARGUMENTS"
|
|
|
|
exit
|