mirror of
https://github.com/myvesta/vesta
synced 2025-08-07 07:14:44 -07:00
Fix for bulk actions
This commit is contained in:
parent
bdc8111b06
commit
bff45302f6
5 changed files with 237 additions and 83 deletions
|
@ -47,37 +47,34 @@ if [ -z "$ip" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Web domain
|
||||
# Working on web domain
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
$BIN/v-add-web-domain $user $domain $ip 'no'
|
||||
return_code=$?
|
||||
check_result $? "can't add web domain" >/dev/null
|
||||
fi
|
||||
|
||||
# Proxy support
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
|
||||
extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls"
|
||||
extentions="$extentions,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav"
|
||||
extentions="$extentions,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
|
||||
$BIN/v-add-web-domain-proxy $user $domain 'default' "$extentions" 'no'
|
||||
# Working on DNS domain
|
||||
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||
$BIN/v-add-dns-domain $user $domain $ip "" "" "" "" "" 'no'
|
||||
check_result $? "can't add dns domain" >/dev/null
|
||||
fi
|
||||
|
||||
# DNS domain
|
||||
if [ ! -z "$DNS_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
|
||||
$BIN/v-add-dns-domain $user $domain $ip 'no'
|
||||
return_code=$?
|
||||
fi
|
||||
|
||||
# Mail domain
|
||||
if [ ! -z "$MAIL_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
|
||||
# Working on mail domain
|
||||
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||
$BIN/v-add-mail-domain $user $domain
|
||||
return_code=$?
|
||||
check_result $? "can't add mail domain" >/dev/null
|
||||
fi
|
||||
|
||||
# Restart services
|
||||
if [ "$restart" != 'no' ] && [ "$return_code" -eq 0 ]; then
|
||||
# Restarting services
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
$BIN/v-restart-proxy
|
||||
check_result $? "can't restart web" > /dev/null
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
check_result $? "can't restart proxy" > /dev/null
|
||||
fi
|
||||
$BIN/v-restart-dns
|
||||
check_result $? "can't restart dns" > /dev/null
|
||||
fi
|
||||
|
||||
|
||||
|
@ -85,4 +82,4 @@ fi
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit $return_code
|
||||
exit
|
||||
|
|
|
@ -16,7 +16,6 @@ restart="${3-yes}"
|
|||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/ip.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
|
@ -34,51 +33,53 @@ 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
|
||||
# Working on Web domain
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |grep "SUSPENDED='no")
|
||||
if [ ! -z "$str" ]; then
|
||||
domain_found='yes'
|
||||
$BIN/v-delete-web-domain $user $domain 'no'
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "can't suspend web" > /dev/null
|
||||
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
|
||||
# Working on DNS domain
|
||||
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf |grep "SUSPENDED='no")
|
||||
if [ ! -z "$str" ]; then
|
||||
domain_found='yes'
|
||||
$BIN/v-delete-dns-domain $user $domain 'no'
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "can't suspend dns" > /dev/null
|
||||
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
|
||||
# Working on Mail domain
|
||||
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf |grep "SUSPENDED='no")
|
||||
if [ ! -z "$str" ]; then
|
||||
domain_found='yes'
|
||||
$BIN/v-delete-mail-domain $user $domain
|
||||
if [ $? -ne 0 ]; then
|
||||
exit $E_RESTART
|
||||
fi
|
||||
check_result $? "can't suspend mail" > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check domain status
|
||||
if [ -z "$check_web" ] && [ -z "$check_dns" ] && [ -z "$check_mail" ]; then
|
||||
# Checking domain search result
|
||||
if [ -z "$domain_found" ]; then
|
||||
echo "Error: domain $domain doesn't exist"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Restart services
|
||||
# Restarting services
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
$BIN/v-restart-proxy
|
||||
check_result $? "can't restart web" > /dev/null
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
check_result $? "can't restart proxy" > /dev/null
|
||||
fi
|
||||
$BIN/v-restart-dns
|
||||
check_result $? "can't restart dns" > /dev/null
|
||||
fi
|
||||
|
||||
|
||||
|
|
90
bin/v-suspend-domain
Executable file
90
bin/v-suspend-domain
Executable file
|
@ -0,0 +1,90 @@
|
|||
#!/bin/bash
|
||||
# info: suspend web/dns/mail domain
|
||||
# options: USER DOMAIN
|
||||
#
|
||||
# The function suspends web/dns/mail domain.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
restart="${3-yes}"
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.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 #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Working on Web domain
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |grep "SUSPENDED='no")
|
||||
if [ ! -z "$str" ]; then
|
||||
domain_found='yes'
|
||||
$BIN/v-suspend-web-domain $user $domain 'no'
|
||||
check_result $? "can't suspend web" > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Working on DNS domain
|
||||
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf |grep "SUSPENDED='no")
|
||||
if [ ! -z "$str" ]; then
|
||||
domain_found='yes'
|
||||
$BIN/v-suspend-dns-domain $user $domain 'no'
|
||||
check_result $? "can't suspend dns" > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Working on Mail domain
|
||||
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf |grep "SUSPENDED='no")
|
||||
if [ ! -z "$str" ]; then
|
||||
domain_found='yes'
|
||||
$BIN/v-suspend-mail-domain $user $domain
|
||||
check_result $? "can't suspend mail" > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Checking domain search result
|
||||
if [ -z "$domain_found" ]; then
|
||||
echo "Error: domain $domain doesn't exist"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Restarting services
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
check_result $? "can't restart web" > /dev/null
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
check_result $? "can't restart proxy" > /dev/null
|
||||
fi
|
||||
$BIN/v-restart-dns
|
||||
check_result $? "can't restart dns" > /dev/null
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
89
bin/v-unsuspend-domain
Executable file
89
bin/v-unsuspend-domain
Executable file
|
@ -0,0 +1,89 @@
|
|||
#!/bin/bash
|
||||
# info: unsuspend web/dns/mail domain
|
||||
# options: USER DOMAIN
|
||||
#
|
||||
# The function unsuspends web/dns/mail domain.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$2
|
||||
restart="${3-yes}"
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN'
|
||||
validate_format 'user' 'domain'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Working on Web domain
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |grep "SUSPENDED='yes")
|
||||
if [ ! -z "$str" ]; then
|
||||
domain_found='yes'
|
||||
$BIN/v-unsuspend-web-domain $user $domain 'no'
|
||||
check_result $? "can't suspend web" > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Working on DNS domain
|
||||
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf |grep "SUSPENDED='yes")
|
||||
if [ ! -z "$str" ]; then
|
||||
domain_found='yes'
|
||||
$BIN/v-unsuspend-dns-domain $user $domain 'no'
|
||||
check_result $? "can't suspend dns" > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Working on Mail domain
|
||||
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf |grep "SUSPENDED='yes")
|
||||
if [ ! -z "$str" ]; then
|
||||
domain_found='yes'
|
||||
$BIN/v-unsuspend-mail-domain $user $domain
|
||||
check_result $? "can't suspend mail" > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Checking domain search result
|
||||
if [ -z "$domain_found" ]; then
|
||||
echo "Error: domain $domain doesn't exist"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
# Restarting services
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
check_result $? "can't restart web" > /dev/null
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
check_result $? "can't restart proxy" > /dev/null
|
||||
fi
|
||||
$BIN/v-restart-dns
|
||||
check_result $? "can't restart dns" > /dev/null
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
|
@ -17,59 +17,36 @@ $action = $_POST['action'];
|
|||
|
||||
if ($_SESSION['user'] == 'admin') {
|
||||
switch ($action) {
|
||||
case 'delete': $cmd='v-delete-web-domain';
|
||||
$cmd_dns='v-delete-dns-domain';
|
||||
$cmd_mail='v-delete-mail-domain';
|
||||
case 'delete': $cmd='v-delete-domain';
|
||||
break;
|
||||
case 'suspend': $cmd='v-suspend-web-domain';
|
||||
$cmd_dns='v-suspend-dns-domain';
|
||||
$cmd_mail='v-suspend-mail-domain';
|
||||
case 'suspend': $cmd='v-suspend-domain';
|
||||
break;
|
||||
case 'unsuspend': $cmd='v-unsuspend-web-domain';
|
||||
$cmd_dns='v-unsuspend-dns-domain';
|
||||
$cmd_mail='v-unsuspend-mail-domain';
|
||||
case 'unsuspend': $cmd='v-unsuspend-domain';
|
||||
break;
|
||||
default: header("Location: /list/web/"); exit;
|
||||
}
|
||||
} else {
|
||||
switch ($action) {
|
||||
case 'delete': $cmd='v-delete-web-domain';
|
||||
$cmd_dns='v-delete-dns-domain';
|
||||
$cmd_mail='v-delete-mail-domain';
|
||||
case 'delete': $cmd='v-web-domain';
|
||||
break;
|
||||
default: header("Location: /list/web/"); exit;
|
||||
}
|
||||
}
|
||||
|
||||
print_r($_POST);
|
||||
|
||||
foreach ($domain as $value) {
|
||||
// WEB
|
||||
$value = escapeshellarg($value);
|
||||
exec (VESTA_CMD.$cmd." ".$user." ".$value." no", $output, $return_var);
|
||||
$restart_web = 'yes';
|
||||
|
||||
// DNS
|
||||
if ($return_var == 0) {
|
||||
exec (VESTA_CMD."v-list-dns-domain ".$user." ".$value." json", $output, $lreturn_var);
|
||||
if ($lreturn_var == 0 ) {
|
||||
exec (VESTA_CMD.$cmd_dns." ".$user." ".$value." no", $output, $return_var);
|
||||
$restart_dns = 'yes';
|
||||
}
|
||||
}
|
||||
|
||||
// Mail
|
||||
if ($return_var == 0) {
|
||||
exec (VESTA_CMD."v-list-mail-domain ".$user." ".$value." json", $output, $lreturn_var);
|
||||
if ($lreturn_var == 0 ) {
|
||||
exec (VESTA_CMD.$cmd_mail." ".$user." ".$value." no", $output, $return_var);
|
||||
}
|
||||
}
|
||||
echo VESTA_CMD.$cmd." ".$user." ".$value." no";
|
||||
// exec (VESTA_CMD.$cmd." ".$user." ".$value." no", $output, $return_var);
|
||||
$restart='yes';
|
||||
}
|
||||
|
||||
if (!empty($restart_web)) {
|
||||
exit();
|
||||
|
||||
if (isset($restart)) {
|
||||
exec (VESTA_CMD."v-restart-web", $output, $return_var);
|
||||
}
|
||||
|
||||
if (!empty($restart_dns)) {
|
||||
exec (VESTA_CMD."v-restart-proxy", $output, $return_var);
|
||||
exec (VESTA_CMD."v-restart-dns", $output, $return_var);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue