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

61 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# info: suspend database
# options: USER DATABASE
#
# The function for suspending a certain user 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) suspend_mysql_database ;;
pgsql) suspend_pgsql_database ;;
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Updating db value
update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'yes'
increase_user_value "$user" '$SUSPENDED_DB'
# Logging
log_event "$OK" "$ARGUMENTS"
exit