mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 18:49:21 -07:00
simplified domain deletion
This commit is contained in:
parent
1c0de53944
commit
8871eae499
2 changed files with 81 additions and 21 deletions
80
bin/v-delete-domain
Executable file
80
bin/v-delete-domain
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/bin/bash
|
||||
# info: delete web/dns/mail domain
|
||||
# options: USER DOMAIN
|
||||
#
|
||||
# The function deletes web/dns/mail domain.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/ip.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN'
|
||||
validate_format 'user' 'domain'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Web domain
|
||||
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
|
||||
check_web=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
|
||||
if [ ! -z "$check_web" ]; then
|
||||
$BIN/v-delete-web-domain $user $domain
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $?
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# DNS domain
|
||||
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
|
||||
check_dns=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||
if [ ! -z "$check_dns" ]; then
|
||||
$BIN/v-delete-dns-domain $user $domain
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $?
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Mail domain
|
||||
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
|
||||
check_mail=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf)
|
||||
if [ ! -z "$check_mail" ]; then
|
||||
$BIN/v-delete-mail-domain $user $domain
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $?
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check domain status
|
||||
if [ -z "$check_web" ] && [ -z "$check_dns" ] && [ -z "$check_mail" ]; then
|
||||
echo "Error: domain $domain doesn't exist"
|
||||
log_event "$E_NOTEXIST $EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
|
@ -13,29 +13,9 @@ if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
|
|||
if (!empty($_GET['domain'])) {
|
||||
$v_username = escapeshellarg($user);
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
exec (VESTA_CMD."v-delete-web-domain ".$v_username." ".$v_domain, $output, $return_var);
|
||||
exec (VESTA_CMD."v-delete-domain ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
|
||||
// DNS
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $lreturn_var);
|
||||
if ($lreturn_var == 0 ) {
|
||||
exec (VESTA_CMD."v-delete-dns-domain ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
}
|
||||
|
||||
// Mail
|
||||
if (empty($_SESSION['error_msg'])) {
|
||||
exec (VESTA_CMD."v-list-mail-domain ".$v_username." ".$v_domain." json", $output, $lreturn_var);
|
||||
if ($lreturn_var == 0 ) {
|
||||
exec (VESTA_CMD."v-delete-mail-domain ".$v_username." ".$v_domain, $output, $return_var);
|
||||
check_return_code($return_var,$output);
|
||||
unset($output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$back = $_SESSION['back'];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue