mirror of
https://github.com/myvesta/vesta.git
synced 2024-11-03 04:00:20 -08:00
92 lines
2.5 KiB
Bash
Executable File
92 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: unsuspend web domain
|
|
# options: USER DOMAIN
|
|
#
|
|
# The function of unsuspending the domain.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
user=$1
|
|
domain=$2
|
|
domain_idn=$2
|
|
restart=$3
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/func/domain.sh
|
|
source $VESTA/func/ip.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
# Additional argument formatting
|
|
format_domain
|
|
format_domain_idn
|
|
# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ?
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '2' "$#" 'USER DOMAIN [RESTART]'
|
|
is_format_valid 'user' 'domain'
|
|
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
|
is_object_valid 'user' 'USER' "$user"
|
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
|
is_object_suspended 'web' 'DOMAIN' "$domain"
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Parsing domain values
|
|
get_domain_values 'web'
|
|
SUSPENDED='no'
|
|
local_ip=$(get_real_ip $IP)
|
|
|
|
# Preparing domain values for the template substitution
|
|
prepare_web_domain_values
|
|
|
|
# Rebuilding vhost
|
|
del_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
|
add_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
|
if [ "$SSL" = 'yes' ]; then
|
|
del_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
|
add_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
|
fi
|
|
|
|
# Rebuilding proxy configuration
|
|
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
|
del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
|
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
|
if [ "$SSL" = 'yes' ]; then
|
|
del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
|
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
|
fi
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Updating config
|
|
update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no'
|
|
decrease_user_value "$user" '$SUSPENDED_WEB'
|
|
|
|
# Restarting web server
|
|
$BIN/v-restart-web $restart
|
|
check_result $? "Web restart failed" >/dev/null
|
|
|
|
$BIN/v-restart-proxy $restart
|
|
check_result $? "Proxy restart failed" >/dev/null
|
|
|
|
# Logging
|
|
log_event "$OK" "$ARGUMENTS"
|
|
|
|
exit
|