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

@ -32,7 +32,7 @@ source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
check_args '2' "$#" 'USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART]'
validate_format 'user' 'domain' 'extentions'
is_format_valid 'user' 'domain' 'extentions'
is_system_enabled "$PROXY_SYSTEM" 'PROXY_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
@ -51,44 +51,15 @@ is_proxy_template_valid $template
# Defining domain parameters
get_domain_values 'web'
PROXY="$template"
PROXY_EXT="$extentions"
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
ip=$(get_real_ip $IP)
local_ip=$(get_real_ip $IP)
# Preparing domain values for the template substitution
upd_web_domain_values
add_web_config
PROXY_EXT="$extentions"
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
# Set permission and ownership
chown root:$user $conf
chmod 640 $conf
# Checking proxy config
proxy_conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
if [ -z "$(grep "$conf" $proxy_conf)" ]; then
echo "include $conf;" >> $proxy_conf
fi
# Checking ssl
# Adding proxy for ssl
if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
add_web_config
chown root:$user $conf
chmod 640 $conf
proxy_conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
if [ -z "$(grep "$conf" $proxy_conf)" ]; then
echo "include $conf;" >> $proxy_conf
fi
fi
# Running template trigger
if [ -x $WEBTPL/$PROXY_SYSTEM/$template.sh ]; then
$WEBTPL/$PROXY_SYSTEM/$template.sh $user $domain $ip $HOMEDIR $docroot
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
fi
@ -107,6 +78,6 @@ if [ "$restart" != 'no' ]; then
fi
log_history "enabled proxy support for $domain"
log_event "$OK" "$EVENT"
log_event "$OK" "$ARGUMENTS"
exit