myvesta/bin/v-delete-web-domains
2015-05-29 01:53:31 +03:00

64 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# info: delete web domains
# options: USER [RESTART]
#
# The function deteles all user's webdomains.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
restart=$2
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'USER [RESTART]'
validate_format 'user'
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Starting delete loop
for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do
$BIN/v-delete-web-domain "$user" "$domain" 'no'
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Restart web server
if [ "$restart" != 'no' ]; then
$BIN/v-restart-web
if [ $? -ne 0 ]; then
exit $E_RESTART
fi
if [ ! -z "$PROXY_SYSTEM" ]; then
$BIN/v-restart-proxy
if [ $? -ne 0 ]; then
exit $E_RESTART
fi
fi
fi
# Logging
log_event "$OK" "$EVENT"
exit