web function refactoring

This commit is contained in:
Serghey Rodin 2016-06-09 17:05:41 +03:00
commit 872cd3ac45
20 changed files with 744 additions and 1239 deletions

View file

@ -1,8 +1,8 @@
#!/bin/bash
# info: change web domain ip address
# options: USER DOMAIN IP [RESTART]
# info: change web domain ip
# options: USER DOMAIN DOMAIN [RESTART]
#
# The call is used for changing the site ip address.
# The call is used for changing domain ip
#----------------------------------------------------------#
@ -13,7 +13,7 @@
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
ip=$3
new_domain=$(echo $3 |tr '[:upper:]' '[:lower:]')
restart=$4
# Includes
@ -28,7 +28,7 @@ source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
check_args '3' "$#" 'USER DOMAIN IP [RESTART]'
validate_format 'user' 'domain' 'ip'
is_format_valid 'user' 'domain' 'ip'
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
@ -42,33 +42,22 @@ is_ip_avalable
# Action #
#----------------------------------------------------------#
# Define variable for replace
# Preparing variables for vhost replace
get_domain_values 'web'
ip=$(get_real_ip $ip)
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
old=$(get_real_ip $IP)
new=$ip
replace_web_config
# Checking SSL
# Replacing vhost
replace_web_config "$WEB_SYSTEM" "$TPL.tpl"
if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
replace_web_config
replace_web_config "$WEB_SYSTEM" "$TPL.stpl"
fi
# Checking proxy
# Replacing proxy vhost
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
replace_web_config
# Checking SSL proxy
if [ "$SSL" = 'yes' ] && [ ! -z "$PROXY" ]; then
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
replace_web_config
replace_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
if [ "$SSL" = 'yes' ]; then
replace_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
fi
fi
@ -97,6 +86,6 @@ fi
# Logging
log_history "changed web domain $domain ip to $3"
log_event "$OK" "$EVENT"
log_event "$OK" "$ARGUMENTS"
exit