1
0
mirror of https://github.com/serghey-rodin/vesta.git synced 2025-03-11 20:26:30 -07:00
vesta/bin/v-update-database-disk

61 lines
1.6 KiB
Plaintext
Raw Normal View History

2013-01-19 23:07:26 +02:00
#!/bin/bash
# info: update database disk usage
# options: USER DATABASE
#
2015-11-06 17:38:58 +02:00
# The function recalculates disk usage for specific database.
2013-01-19 23:07:26 +02:00
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2013-01-19 23:07:26 +02:00
user=$1
database=$2
# Includes
source $VESTA/func/main.sh
source $VESTA/func/db.sh
source $VESTA/conf/vesta.conf
2013-01-19 23:07:26 +02:00
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'USER DATABASE'
is_format_valid 'user' 'database'
2013-05-29 13:16:09 +03:00
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
2013-01-19 23:07:26 +02:00
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"
2013-01-19 23:07:26 +02:00
exit