vesta/bin/v-unsuspend-database
2016-06-09 16:55:35 +03:00

60 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# info: unsuspend database
# options: USER DATABASE
#
# The function for unsuspending 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_valid 'db' 'DB' "$database"
is_object_suspended 'db' 'DB' "$database"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get database values
get_database_values
# Switching on db type
case $TYPE in
mysql) unsuspend_mysql_database ;;
pgsql) unsuspend_pgsql_database ;;
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Updating db value
update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'no'
decrease_user_value "$user" '$SUSPENDED_DB'
# Logging
log_event "$OK" "$ARGUMENTS"
exit