mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 02:28:05 -07:00
When deleting a domain, also delete the database if the domain has a database.
This commit is contained in:
parent
01e4890a97
commit
2c819e5bfc
2 changed files with 74 additions and 3 deletions
70
bin/v-delete-database-of-domain
Normal file
70
bin/v-delete-database-of-domain
Normal file
|
@ -0,0 +1,70 @@
|
|||
#!/bin/bash
|
||||
# info: change domain and database owner
|
||||
# options: DOMAIN USER
|
||||
#
|
||||
# The function of changing domain and database ownership.
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
whoami=$(whoami)
|
||||
if [ "$whoami" != "root" ]; then
|
||||
echo "You must be root to execute this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Importing system environment
|
||||
source /etc/profile
|
||||
|
||||
# Argument definition
|
||||
domain=$1
|
||||
|
||||
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
|
||||
USER=$user
|
||||
|
||||
# Includes
|
||||
source /usr/local/vesta/func/main.sh
|
||||
|
||||
if [ -z "$user" ]; then
|
||||
check_result $E_NOTEXIST "domain $domain doesn't exist"
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'DOMAIN'
|
||||
is_format_valid 'domain'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
RET=$OK
|
||||
|
||||
# echo "================================="
|
||||
r=$(/usr/local/vesta/bin/v-get-database-credentials-of-domain $domain)
|
||||
# echo $r
|
||||
eval $r
|
||||
# echo "================================="
|
||||
|
||||
if [ ! -z "$DATABASE_NAME" ]; then
|
||||
echo "=== v-delete-database $USER $DATABASE_NAME"
|
||||
/usr/local/vesta/bin/v-delete-database $USER $DATABASE_NAME
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "=== v-delete-database failed"
|
||||
RET=$E_NOTEXIST
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
log_event "$RET" "$ARGUMENTS"
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue