Initial
This commit is contained in:
66
bin/v-unsuspend-database
Executable file
66
bin/v-unsuspend-database
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
# info: unsuspend database
|
||||
# options: USER DATABASE
|
||||
#
|
||||
# example: v-unsuspend-database admin mydb
|
||||
#
|
||||
# This function for unsuspending database.
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variables & Functions #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument definition
|
||||
user=$1
|
||||
database=$2
|
||||
|
||||
# Includes
|
||||
# shellcheck source=/etc/hestiacp/hestia.conf
|
||||
source /etc/hestiacp/hestia.conf
|
||||
# shellcheck source=/usr/local/hestia/func/main.sh
|
||||
source $HESTIA/func/main.sh
|
||||
# shellcheck source=/usr/local/hestia/func/db.sh
|
||||
source $HESTIA/func/db.sh
|
||||
# load config file
|
||||
source_conf "$HESTIA/conf/hestia.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"
|
||||
|
||||
# Perform verification if read-only mode is enabled
|
||||
check_hestia_demo_mode
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Get database values
|
||||
get_database_values
|
||||
|
||||
# Switching on db type
|
||||
case $TYPE in
|
||||
mysql) unsuspend_mysql_database ;;
|
||||
pgsql) unsuspend_pgsql_database ;;
|
||||
esac
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Hestia #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating db value
|
||||
update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'no'
|
||||
decrease_user_value "$user" '$SUSPENDED_DB'
|
||||
|
||||
# Logging
|
||||
$BIN/v-log-action "system" "Info" "Database" "Unsuspended database (User: $user, Database: $database)."
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
Reference in New Issue
Block a user