@@ -39,17 +39,17 @@ user_domains=0
3939user_ssl=0
4040user_aliases=0
4141suspended_web=0
42-
43- # Clean up old config
44- rm -f $HOMEDIR /$user /conf/tmp_* .conf
45-
46- # Defining config
4742conf=$USER_DATA /web.conf
4843fields=' $DOMAIN'
4944nohead=1
45+ domain_counter=0
46+
47+ # Clean up old config
48+ rm -f $HOMEDIR /$user /conf/tmp_* .conf
5049
5150# Starting loop
52- for domain in $( shell_list) ; do
51+ for domain in $( shell_list) ; do
52+ (( ++ domain_counter))
5353
5454 # Rebuilding directories
5555 mkdir -p $HOMEDIR /$user /web/$domain \
@@ -241,57 +241,70 @@ for domain in $(shell_list) ; do
241241
242242done
243243
244- # Renaming tmp config
245- tmp_conf=" $HOMEDIR /$user /conf/web/tmp_httpd.conf"
246- conf=" $HOMEDIR /$user /conf/web/httpd.conf"
247- if [ -e " $tmp_conf " ]; then
248- mv $tmp_conf $conf
249- fi
244+ # Config path
245+ httpd_conf=' /etc/httpd/conf.d/vesta.conf'
246+ nginx_conf=' /etc/nginx/conf.d/vesta_users.conf'
250247
251- # Checking include in main httpd.conf
252- main_conf=' /etc/httpd/conf.d/vesta.conf'
253- main_conf_check=$( grep " $conf " $main_conf )
254- if [ ! -z " $domain " ] && [ -z " $main_conf_check " ]; then
255- echo " Include $conf " >> $main_conf
256- fi
248+ # Checking if there is at least 1 domain
249+ if [ " $domain_counter " -lt 1 ]; then
250+
251+ # Deleting web configs
252+ rm -f $HOMEDIR /$user /conf/web/*
253+ sed -i " /.*\/$user \/.*httpd.conf/d" $httpd_conf
254+ if [ -e " $nginx_conf " ]; then
255+ sed -i " /.*\/$user \/.*nginx.conf/d" $nginx_conf
256+ fi
257+
258+ else
257259
258- # Checking ssl
259- if [ " $ssl_change " = ' yes' ]; then
260- tmp_conf=" $HOMEDIR /$user /conf/web/tmp_shttpd.conf"
261- conf=" $HOMEDIR /$user /conf/web/shttpd.conf"
260+ # Renaming tmp config
261+ tmp_conf=" $HOMEDIR /$user /conf/web/tmp_httpd.conf"
262+ conf=" $HOMEDIR /$user /conf/web/httpd.conf"
262263 mv $tmp_conf $conf
263264
264- # Checking include in main httpd.conf
265- main_conf_check =$( grep " $conf " $main_conf )
266- if [ -z " $main_conf_check " ]; then
267- echo " Include $conf " >> $main_conf
265+ # Checking httpd.conf include
266+ httpd_include =$( grep " $conf " $httpd_conf )
267+ if [ -z " $httpd_include " ]; then
268+ echo " Include $conf " >> $httpd_conf
268269 fi
269- fi
270270
271- # Checking nginx
272- if [ " $ngix_change " = ' yes' ]; then
273- nginx_conf= ' /etc/nginx/ conf.d/vesta_users .conf'
274- tmp_conf =" $HOMEDIR /$user /conf/web/tmp_nginx .conf"
275- conf= " $HOMEDIR / $user / conf/web/nginx.conf "
276- mv $tmp_conf $conf
271+ # Checking ssl
272+ if [ " $ssl_change " = ' yes' ]; then
273+ tmp_conf= " $HOMEDIR / $user / conf/web/tmp_shttpd .conf"
274+ conf =" $HOMEDIR /$user /conf/web/shttpd .conf"
275+ mv $tmp_conf $ conf
276+ fi
277277
278- nginx_conf_check=$( grep " $conf " $nginx_conf )
279- if [ -z " $nginx_conf_check " ]; then
280- echo " include $conf ;" >> $nginx_conf
278+ # Checking ssl include
279+ httpd_include=$( grep " $conf " $httpd_conf )
280+ if [ -z " $httpd_include " ]; then
281+ echo " Include $conf " >> $httpd_conf
282+ fi
283+
284+ # Checking nginx
285+ if [ " $ngix_change " = ' yes' ]; then
286+ tmp_conf=" $HOMEDIR /$user /conf/web/tmp_nginx.conf"
287+ conf=" $HOMEDIR /$user /conf/web/nginx.conf"
288+ mv $tmp_conf $conf
289+ fi
290+ nginx_include=$( grep " $conf " $nginx_conf )
291+ if [ -z " $nginx_include " ]; then
292+ echo " include $conf ;" >> $nginx_conf
281293 fi
282294
283295 # Checking ssl for nginx
284- if [ " $ssl_change " = ' yes' ]; then
296+ if [ " $ngix_change " = ' yes ' ] && [ " $ ssl_change" = ' yes' ]; then
285297 tmp_conf=" $HOMEDIR /$user /conf/web/tmp_snginx.conf"
286298 conf=" $HOMEDIR /$user /conf/web/snginx.conf"
287299 mv $tmp_conf $conf
288- nginx_conf_check =$( grep " $conf " $nginx_conf )
289- if [ -z " $nginx_conf_check " ]; then
290- echo " include $conf ;" >> $nginx_conf
300+ nginx_include =$( grep " $conf " $nginx_conf )
301+ if [ -z " $nginx_include " ]; then
302+ echo " include $conf ;" >> $nginx_conf
291303 fi
292304 fi
293305fi
294306
307+
295308# ----------------------------------------------------------#
296309# Vesta #
297310# ----------------------------------------------------------#
0 commit comments