Files
VestaCP/bin/v-delete-web-domain-proxy

98 lines
2.7 KiB
Plaintext
Raw Normal View History

2013-01-19 23:07:26 +02:00
#!/bin/bash
2013-05-10 11:04:40 +03:00
# info: deleting web domain proxy configuration
2013-01-19 23:07:26 +02:00
# options: USER DOMAIN
#
2013-05-10 11:04:40 +03:00
# The function of deleting the virtualhost proxy configuration.
2013-01-19 23:07:26 +02:00
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2013-01-19 23:07:26 +02:00
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
restart=$3
# Includes
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
source $VESTA/conf/vesta.conf
2013-01-19 23:07:26 +02:00
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain'
2013-05-29 13:16:09 +03:00
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
2013-01-19 23:07:26 +02:00
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
2013-05-10 11:04:40 +03:00
is_object_value_exist 'web' 'DOMAIN' "$domain" '$PROXY'
2013-01-19 23:07:26 +02:00
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining domain parameters
get_domain_values 'web'
2013-05-10 11:04:40 +03:00
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
2014-02-18 01:09:40 +02:00
if [ ! -z "$PROXY_SYSTEM" ]; then
del_web_config
fi
2013-01-19 23:07:26 +02:00
2013-05-10 11:04:40 +03:00
# Checking SSL
2013-01-19 23:07:26 +02:00
if [ "$SSL" = 'yes' ]; then
2013-05-10 11:04:40 +03:00
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
2014-02-18 01:09:40 +02:00
if [ ! -z "$PROXY_SYSTEM" ]; then
del_web_config
fi
2013-01-19 23:07:26 +02:00
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Update config
2013-05-10 11:04:40 +03:00
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' ''
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' ''
2014-02-18 01:09:40 +02:00
if [ -z "$PROXY_SYSTEM" ]; then
exit
fi
2013-05-10 11:04:40 +03:00
# Checking last SSL proxy
conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
last_sproxy=$(grep "SSL='yes'" $USER_DATA/web.conf)
if [ -z "$last_sproxy" ]; then
sed -i "/.*\/$user\/.*s$PROXY_SYSTEM.conf/d" $conf
rm -f $HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf
2013-01-19 23:07:26 +02:00
fi
2013-05-10 11:04:40 +03:00
# Checking last proxy
last_proxy=$(grep -v "PROXY=''" $USER_DATA/web.conf)
if [ -z "$last_proxy" ]; then
sed -i "/.*\/$user\/.*$PROXY_SYSTEM.conf/d" $conf
rm -f $HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf
2013-01-19 23:07:26 +02:00
fi
2013-05-10 11:04:40 +03:00
# Restart proxy server
2013-01-19 23:07:26 +02:00
if [ "$restart" != 'no' ]; then
2013-05-10 11:04:40 +03:00
$BIN/v-restart-proxy
2015-10-28 16:34:41 +02:00
check_result $? "Proxy restart failed" >/dev/null
2013-01-19 23:07:26 +02:00
fi
# Logging
2013-05-10 11:04:40 +03:00
log_history "disabled proxy support for $domain"
2013-01-19 23:07:26 +02:00
log_event "$OK" "$EVENT"
exit