Files
VestaCP/bin/v_delete_db_dbases
2012-01-03 21:47:10 +02:00

74 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# info: delete user databases
# options: user
#
# The function deletes all user databases.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/db.func
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
# Checking web system is enabled
is_system_enabled 'db'
# Checking user
is_user_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/db.conf"
# Defining fileds to select
field='$DB'
# Defining search string
search_string="SUSPEND='no'"
# Parsing unsuspeneded domains
databases=$(db_clear_search)
# Starting delete loop
for database in $databases; do
$V_BIN/v_delete_db_base "$user" "$database"
rv="$?"
if [ "$rv" -ne '0' ]; then
log_event 'debug' "$rv $V_EVENT"
exit $rv
fi
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit