Skip to content

Commit 7ce7cf1

Browse files
committed
8k alias fix + new tpl convention
1 parent 9ca747f commit 7ce7cf1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+724
-911
lines changed

bin/v_add_ssl_certificate

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# Argument defenition
99
user=$1
10-
cert=$2
10+
ssl=$2
1111

1212
# Importing variables
1313
source $VESTA/conf/vars.conf
@@ -19,10 +19,10 @@ source $V_FUNC/cert.func
1919
#----------------------------------------------------------#
2020

2121
# Checking arg number
22-
check_args '2' "$#" 'user certificate'
22+
check_args '2' "$#" 'user ssl_certificate'
2323

2424
# Checking argument format
25-
format_validation 'user' 'certificate'
25+
format_validation 'user' 'ssl'
2626

2727
# Checking user
2828
is_user_valid
@@ -42,16 +42,16 @@ is_cert_valid "$V_TMP"
4242
#----------------------------------------------------------#
4343

4444
# Adding certificate to user dir
45-
mv $V_TMP/$cert.crt $V_USERS/$user/cert/
46-
mv $V_TMP/$cert.key $V_USERS/$user/cert/
45+
mv $V_TMP/$ssl.crt $V_USERS/$user/cert/
46+
mv $V_TMP/$ssl.key $V_USERS/$user/cert/
4747

4848

4949
#----------------------------------------------------------#
5050
# Vesta #
5151
#----------------------------------------------------------#
5252

5353
# Logging
54-
log_history "$V_EVENT" "v_del_ssl_certificate $user $cert"
54+
log_history "$V_EVENT" "v_del_ssl_certificate $user $ssl"
5555
log_event 'system' "$V_EVENT"
5656

5757
exit

bin/v_add_web_domain

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ template=${4-default}
1414

1515
# Importing variables
1616
source $VESTA/conf/vars.conf
17+
source $V_CONF/vesta.conf
1718
source $V_FUNC/shared.func
1819
source $V_FUNC/domain.func
1920
source $V_FUNC/ip.func
@@ -66,6 +67,7 @@ is_template_valid "web"
6667
#----------------------------------------------------------#
6768

6869
# Defining domain aliases
70+
IP=$ip
6971
ip_name=$(get_ip_name)
7072
ip_name_idn=$(idn -t --quiet -a "$ip_name")
7173
domain_alias="www.$domain"
@@ -75,16 +77,19 @@ if [ ! -z "$ip_name" ]; then
7577
domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn"
7678
aliases="$domain_alias,$domain_alias_dash"
7779
aliases_idn="$domain_alias_idn,$domain_alias_dash_idn"
80+
alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn"
7881
else
7982
aliases="$domain_alias"
8083
aliases_idn="$domain_alias_idn"
84+
alias_string="ServerAlias $domain_alias_idn"
8185
fi
8286

8387
# Defining vars for add_config function
84-
web_port=$(get_config_value '$WEB_PORT')
8588
group="$user"
8689
email="$user@$domain"
8790
docroot="$V_HOME/$user/web/$domain/public_html"
91+
docroot_string="DocumentRoot $docroot"
92+
8893
conf="$V_HOME/$user/conf/httpd.conf"
8994
tpl_file="$V_WEBTPL/apache_$template.tpl"
9095

@@ -96,9 +101,18 @@ done
96101

97102
# Checking error log status
98103
if [ "$ELOG" = 'no' ]; then
99-
elog=' #'
104+
elog='#'
105+
else
106+
elog=''
107+
fi
108+
109+
# Checking cgi
110+
if [ "$CGI" != 'yes' ]; then
111+
cgi='#'
112+
cgi_option='-ExecCGI'
100113
else
101-
elog=' '
114+
cgi=''
115+
cgi_option='+ExecCGI'
102116
fi
103117

104118
# Adding domain to the httpd.conf
@@ -177,7 +191,7 @@ fi
177191
#----------------------------------------------------------#
178192

179193
# Increasing ip value
180-
increase_ip_value
194+
increase_ip_value "$ip"
181195

182196
# Increasing domain value
183197
increase_user_value "$user" '$U_WEB_DOMAINS'
@@ -189,7 +203,7 @@ v_str="$v_str U_DISK='0'"
189203
v_str="$v_str U_BANDWIDTH='0'"
190204
v_str="$v_str TPL='$template'"
191205
v_str="$v_str ALIAS='$aliases'"
192-
v_str="$v_str $template_data" # Inserting PHP,CGI and ELOG keys
206+
v_str="$v_str $template_data" # Inserting PHP, CGI and ELOG keys
193207
v_str="$v_str STATS='' STATS_AUTH=''"
194208
v_str="$v_str SSL_HOME='' SSL_CERT=''"
195209
v_str="$v_str NGINX='' NGINX_EXT='' SUSPEND='no' DATE='$V_DATE'"

bin/v_add_web_domain_alias

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
1414

1515
# Importing variables
1616
source $VESTA/conf/vars.conf
17+
source $V_CONF/vesta.conf
1718
source $V_FUNC/shared.func
1819
source $V_FUNC/domain.func
1920

@@ -62,36 +63,46 @@ is_package_full 'web_alias'
6263
# Action #
6364
#----------------------------------------------------------#
6465

65-
# Defining params for change function
66-
tpl_name=$(get_web_domain_value '$TPL')
67-
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
66+
# Parsing domain values
67+
get_web_domain_values
68+
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
6869
conf="$V_HOME/$user/conf/httpd.conf"
69-
search_phrase='ServerAlias'
7070

71-
# Defining new alias string
72-
curr_alias=$(get_web_domain_value '$ALIAS')
73-
if [ -z "$curr_alias" ]; then
74-
new_alias="$dom_alias"
75-
new_alias_idn="$dom_alias_idn"
71+
# Parsing domain aliases
72+
if [ -z "$ALIAS" ]; then
73+
ALIAS="$dom_alias"
7674
else
77-
new_alias="$curr_alias,$dom_alias"
78-
new_alias_idn=$(idn -t --quiet -a "$curr_alias,$dom_alias")
75+
ALIAS="$ALIAS,$dom_alias"
7976
fi
8077

81-
# Defining replace string
82-
str_repl=" ServerAlias ${new_alias_idn//,/ }"
78+
# Preparing domain values for the template substitution
79+
upd_web_domain_values
8380

84-
# Adding alias
85-
change_web_config
81+
# Recreating vhost
82+
del_web_config
83+
add_web_config
8684

87-
# Checking ssl domain
88-
cert=$(get_web_domain_value '$SSL_CERT')
89-
if [ ! -z "$cert" ]; then
90-
91-
# Defining params for change function
92-
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
85+
if [ ! -z "$SSL_CERT" ]; then
86+
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
9387
conf="$V_HOME/$user/conf/shttpd.conf"
94-
change_web_config
88+
del_web_config
89+
add_web_config
90+
fi
91+
92+
# Checking nginx
93+
if [ ! -z "$NGINX" ]; then
94+
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
95+
conf="$V_HOME/$user/conf/nginx.conf"
96+
del_web_config
97+
add_web_config
98+
99+
if [ ! -z "$SSL_CERT" ]; then
100+
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
101+
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
102+
conf="$V_HOME/$user/conf/snginx.conf"
103+
del_web_config
104+
add_web_config
105+
fi
95106
fi
96107

97108

@@ -100,7 +111,7 @@ fi
100111
#----------------------------------------------------------#
101112

102113
# Adding new alias
103-
update_web_domain_value '$ALIAS' "$new_alias"
114+
update_web_domain_value '$ALIAS' "$ALIAS"
104115

105116
# Adding task to the vesta pipe
106117
restart_schedule 'web'

bin/v_add_web_domain_cgi

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
1212

1313
# Importing variables
1414
source $VESTA/conf/vars.conf
15+
source $V_CONF/vesta.conf
1516
source $V_FUNC/shared.func
1617
source $V_FUNC/domain.func
1718

@@ -49,36 +50,25 @@ is_web_domain_key_empty '$CGI'
4950
# Action #
5051
#----------------------------------------------------------#
5152

52-
# Get template name
53-
tpl_name=$(get_web_domain_value '$TPL')
54-
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
55-
56-
# Defining params for ScriptAlias
53+
# Parsing domain values
54+
get_web_domain_values
55+
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
5756
conf="$V_HOME/$user/conf/httpd.conf"
58-
search_phrase='ScriptAlias '
59-
str_repl=" ScriptAlias /cgi-bin/ $V_HOME/$user/web/$domain/cgi-bin/"
60-
change_web_config
57+
CGI='yes'
6158

62-
# Defining params for Options
63-
search_phrase='Options '
64-
str_repl=' Options +Includes -Indexes +ExecCGI'
65-
change_web_config
59+
# Preparing domain values for the template substitution
60+
upd_web_domain_values
6661

67-
# Checking ssl
68-
cert=$(get_web_domain_value '$SSL_CERT')
69-
if [ ! -z "$cert" ]; then
62+
# Recreating vhost
63+
del_web_config
64+
add_web_config
7065

71-
# Defining params for ScriptAlias
72-
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
66+
# Checking ssl
67+
if [ ! -z "$SSL_CERT" ]; then
68+
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
7369
conf="$V_HOME/$user/conf/shttpd.conf"
74-
search_phrase='ScriptAlias '
75-
str_repl=" ScriptAlias /cgi-bin/ $V_HOME/$user/web/$domain/cgi-bin/"
76-
change_web_config
77-
78-
# Defining params for Options
79-
search_phrase='Options '
80-
str_repl=' Options +Includes -Indexes +ExecCGI'
81-
change_web_config
70+
del_web_config
71+
add_web_config
8272
fi
8373

8474

bin/v_add_web_domain_elog

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
1212

1313
# Importing variables
1414
source $VESTA/conf/vars.conf
15+
source $V_CONF/vesta.conf
1516
source $V_FUNC/shared.func
1617
source $V_FUNC/domain.func
1718

@@ -49,35 +50,41 @@ is_web_domain_key_empty '$ELOG'
4950
# Action #
5051
#----------------------------------------------------------#
5152

52-
# Get template name
53-
tpl_name=$(get_web_domain_value '$TPL')
54-
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
55-
56-
# Defining config
53+
# Parsing domain values
54+
get_web_domain_values
55+
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
5756
conf="$V_HOME/$user/conf/httpd.conf"
57+
ELOG='yes'
5858

59-
# Defining search phrase
60-
search_phrase='ErrorLog '
61-
62-
# Defining replace string
63-
str_repl=" ErrorLog /var/log/httpd/domains/$domain.error.log"
59+
# Preparing domain values for the template substitution
60+
upd_web_domain_values
6461

65-
# Adding errolog support
66-
change_web_config
62+
# Recreating vhost
63+
del_web_config
64+
add_web_config
6765

6866
# Checking ssl
69-
cert=$(get_web_domain_value '$SSL_CERT')
70-
if [ ! -z "$cert" ]; then
71-
72-
# Get ssl template name
73-
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
74-
75-
# Defining ssl config
67+
if [ ! -z "$SSL_CERT" ]; then
68+
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
7669
conf="$V_HOME/$user/conf/shttpd.conf"
70+
del_web_config
71+
add_web_config
72+
fi
7773

78-
# Adding errolog support
79-
change_web_config
80-
74+
# Checking nginx
75+
if [ ! -z "$NGINX" ]; then
76+
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
77+
conf="$V_HOME/$user/conf/nginx.conf"
78+
del_web_config
79+
add_web_config
80+
81+
if [ ! -z "$SSL_CERT" ]; then
82+
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
83+
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
84+
conf="$V_HOME/$user/conf/snginx.conf"
85+
del_web_config
86+
add_web_config
87+
fi
8188
fi
8289

8390

0 commit comments

Comments
 (0)