mirror of
https://github.com/myvesta/vesta
synced 2025-08-21 05:44:08 -07:00
web function refactoring
This commit is contained in:
parent
72eddc3319
commit
6168985b98
1 changed files with 34 additions and 47 deletions
|
@ -29,20 +29,21 @@ source $VESTA/conf/vesta.conf
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]'
|
check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]'
|
||||||
validate_format 'user' 'domain' 'template'
|
is_format_valid 'user' 'domain' 'template'
|
||||||
is_system_enabled "$WEB_BACKEND" 'WEB_BACKEND'
|
is_system_enabled "$WEB_BACKEND" 'WEB_BACKEND'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_web_backend_template_valid $template
|
is_web_backend_template_valid $template
|
||||||
is_web_backend_pool_valid
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
prepare_web_backend
|
||||||
|
|
||||||
# Deleting backend
|
# Deleting backend
|
||||||
rm -f $pool/$backend.conf
|
rm -f $pool/$backend.conf
|
||||||
|
|
||||||
|
@ -71,34 +72,26 @@ if [ "$backend" = "$user" ]; then
|
||||||
nohead=1
|
nohead=1
|
||||||
|
|
||||||
for domain in $(shell_list); do
|
for domain in $(shell_list); do
|
||||||
|
|
||||||
# Parsing domain values
|
|
||||||
get_domain_values 'web'
|
get_domain_values 'web'
|
||||||
ip=$(get_real_ip $IP)
|
local_ip=$(get_real_ip $IP)
|
||||||
|
prepare_web_domain_values
|
||||||
|
|
||||||
# Deleting old vhost
|
# Rebuilding vhost
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
del_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
add_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||||
del_web_config
|
|
||||||
|
|
||||||
# Deleting old ssl vhost
|
|
||||||
if [ "$SSL" = 'yes' ]; then
|
if [ "$SSL" = 'yes' ]; then
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
del_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
add_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||||
del_web_config
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Adding new vhost
|
# Rebuilding proxy configuration
|
||||||
upd_web_domain_values
|
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||||
add_web_config
|
if [ "$SSL" = 'yes' ]; then
|
||||||
|
del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||||
# Adding new ssl vhost
|
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||||
if [ "$SSL" = 'yes' ]; then
|
fi
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
|
||||||
add_web_config
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update config
|
# Update config
|
||||||
|
@ -117,31 +110,25 @@ if [ "$backend" = "$user" ]; then
|
||||||
else
|
else
|
||||||
# Parsing domain values
|
# Parsing domain values
|
||||||
get_domain_values 'web'
|
get_domain_values 'web'
|
||||||
ip=$(get_real_ip $IP)
|
local_ip=$(get_real_ip $IP)
|
||||||
|
prepare_web_domain_values
|
||||||
|
|
||||||
# Deleting old vhost
|
# Rebuilding vhost
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
del_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
add_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||||
del_web_config
|
|
||||||
|
|
||||||
# Deleting old ssl vhost
|
|
||||||
if [ "$SSL" = 'yes' ]; then
|
if [ "$SSL" = 'yes' ]; then
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
del_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
add_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||||
del_web_config
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Adding new vhost
|
# Rebuilding proxy configuration
|
||||||
upd_web_domain_values
|
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||||
add_web_config
|
if [ "$SSL" = 'yes' ]; then
|
||||||
|
del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||||
# Adding new ssl vhost
|
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||||
if [ "$SSL" = 'yes' ]; then
|
fi
|
||||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
|
||||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
|
||||||
add_web_config
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update config
|
# Update config
|
||||||
|
@ -166,6 +153,6 @@ fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "changed backend template for $domain to $template"
|
log_history "changed backend template for $domain to $template"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$ARGUMENTS"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue