22# info: add web domain backend
33# options: USER DOMAIN [TEMPLATE] [RESTART]
44#
5- # The call is used for adding web backend configuration for user
5+ # The call is used for adding web backend configuration.
66
77
88# ----------------------------------------------------------#
1212# Argument definition
1313user=$1
1414domain=$2
15- domain_idn=$( idn -t --quiet -a " $domain " )
1615template=${3-default}
16+ restart=$4
1717
1818# Includes
1919source $VESTA /func/main.sh
@@ -26,21 +26,24 @@ source $VESTA/conf/vesta.conf
2626# ----------------------------------------------------------#
2727
2828check_args ' 2' " $# " ' USER DOMAIN [TEMPLATE] [RESTART]'
29- validate_format ' user' ' domain'
30- is_system_enabled " $WEB_SYSTEM " ' WEB_SYSTEM'
3129is_system_enabled " $WEB_BACKEND " ' WEB_BACKEND'
30+ is_object_valid ' user' ' USER' " $user "
3231is_object_unsuspended ' user' ' USER' " $user "
33- is_web_backend_template_valid $template
34- is_web_backend_pool_valid
35- if [ -e " $pool /$backend .conf" ]; then
36- exit
37- fi
32+ is_backend_template_valid " $template "
3833
3934
4035# ----------------------------------------------------------#
4136# Action #
4237# ----------------------------------------------------------#
4338
39+ # Defining pool directory
40+ prepare_web_backend
41+
42+ # Checking backend configuration
43+ if [ -e " $pool /$backend_type .conf" ]; then
44+ exit
45+ fi
46+
4447# Allocating backend port
4548backend_port=9000
4649ports=$( grep -v ' ^;' $pool /* 2> /dev/null | grep listen | grep -o :[0-9].* )
@@ -56,8 +59,7 @@ cat $WEBTPL/$WEB_BACKEND/$template.tpl |\
5659 sed -e " s|%backend_port%|$backend_port |" \
5760 -e " s|%user%|$user |" \
5861 -e " s|%domain%|$domain |" \
59- -e " s|%domain_idn%|$domain_idn |" \
60- -e " s|%backend%|$backend |g" > $pool /$backend .conf
62+ -e " s|%backend%|$backend_type |g" > $pool /$backend_type .conf
6163
6264
6365# ----------------------------------------------------------#
7274
7375# Logging
7476log_history " added $WEB_BACKEND backend configuration for $domain "
75- log_event " $OK " " $EVENT "
77+ log_event " $OK " " $ARGUMENTS "
7678
7779exit
0 commit comments