瀏覽代碼

improving template structure

Serghey Rodin 13 年之前
父節點
當前提交
cd69b7bcdf

+ 3 - 3
bin/v-add-web-domain

@@ -83,7 +83,7 @@ group="$user"
 email="$user@$domain"
 docroot="$HOMEDIR/$user/web/$domain/public_html"
 conf="$HOMEDIR/$user/conf/web/httpd.conf"
-tpl_file="$WEBTPL/apache_$template.tpl"
+tpl_file="$WEBTPL/apache/$template.tpl"
 
 # Adding domain to the httpd.conf
 add_web_config
@@ -146,8 +146,8 @@ chmod 551 $HOMEDIR/$user/web/$domain/logs
 chmod 640 /var/log/httpd/domains/$domain.*
 
 # Running template trigger
-if [ -x $WEBTPL/apache_$template.sh ]; then
-    $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot
+if [ -x $WEBTPL/apache/$template.sh ]; then
+    $WEBTPL/apache/$template.sh $user $domain $ip $HOMEDIR $docroot
 fi
 
 # Checking main vesta httpd config

+ 4 - 4
bin/v-add-web-domain-alias

@@ -49,7 +49,7 @@ is_package_full 'WEB_ALIASES'
 
 # Parsing domain values
 get_domain_values 'web'
-tpl_file="$WEBTPL/apache_$TPL.tpl"
+tpl_file="$WEBTPL/apache/$TPL.tpl"
 conf="$HOMEDIR/$user/conf/web/httpd.conf"
 ip=$(get_real_ip $IP)
 
@@ -68,7 +68,7 @@ del_web_config
 add_web_config
 
 if [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/apache_$TPL.stpl"
+    tpl_file="$WEBTPL/apache/$TPL.stpl"
     conf="$HOMEDIR/$user/conf/web/shttpd.conf"
     del_web_config
     add_web_config
@@ -76,13 +76,13 @@ fi
 
 # Checking nginx
 if [ ! -z "$NGINX" ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.tpl"
     conf="$HOMEDIR/$user/conf/web/nginx.conf"
     del_web_config
     add_web_config
 
     if [ "$SSL" = 'yes' ]; then
-        tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+        tpl_file="$WEBTPL/nginx/$NGINX.stpl"
         conf="$HOMEDIR/$user/conf/web/snginx.conf"
         del_web_config
         add_web_config

+ 2 - 2
bin/v-add-web-domain-nginx

@@ -56,7 +56,7 @@ fi
 get_domain_values 'web'
 NGINX="$template"
 NGINX_EXT="$extentions"
-tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+tpl_file="$WEBTPL/nginx/$NGINX.tpl"
 conf="$HOMEDIR/$user/conf/web/nginx.conf"
 ip=$(get_real_ip $IP)
 
@@ -77,7 +77,7 @@ fi
 
 # Checking ssl
 if [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.stpl"
     conf="$HOMEDIR/$user/conf/web/snginx.conf"
     add_web_config
 

+ 4 - 4
bin/v-add-web-domain-ssl

@@ -63,7 +63,7 @@ chmod 660 $USER_DATA/ssl/$domain.*
 # Parsing domain values
 get_domain_values 'web'
 conf="$HOMEDIR/$user/conf/web/shttpd.conf"
-tpl_file="$WEBTPL/apache_$TPL.stpl"
+tpl_file="$WEBTPL/apache/$TPL.stpl"
 SSL_HOME="$ssl_home"
 ip=$(get_real_ip $IP)
 
@@ -85,8 +85,8 @@ if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
 fi
 
 # Running template trigger
-if [ -x $WEBTPL/apache_$template.sh ]; then
-    $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $sdocroot
+if [ -x $WEBTPL/apache/$template.sh ]; then
+    $WEBTPL/apache/$template.sh $user $domain $ip $HOMEDIR $sdocroot
 fi
 
 # Checking main vesta httpd config
@@ -100,7 +100,7 @@ fi
 if [ ! -z "$NGINX" ]; then
     # Adding domain to the snginx.conf
     conf="$HOMEDIR/$user/conf/web/snginx.conf"
-    tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.stpl"
     add_web_config
 
     chown root:nginx $conf

+ 1 - 1
bin/v-add-web-domain-stats

@@ -51,7 +51,7 @@ get_domain_values 'web'
 upd_web_domain_values
 
 # Adding statistic config
-cat $WEBTPL/$type.tpl |\
+cat $WEBTPL/$type/$type.tpl |\
     sed -e "s/%ip%/$ip/g" \
         -e "s/%web_port%/$WEB_PORT/g" \
         -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \

+ 4 - 4
bin/v-backup-user

@@ -169,14 +169,14 @@ then
         # Apache config
         if [ "$WEB_SYSTEM" = 'apache' ]; then
             # Parsing httpd.conf
-            tpl_file="$WEBTPL/apache_$TPL.tpl"
+            tpl_file="$WEBTPL/apache/$TPL.tpl"
             conf="$HOMEDIR/$user/conf/web/httpd.conf"
             get_web_config_brds
             sed -n "$top_line,$bottom_line p" $conf > conf/httpd.conf
 
             # SSL check
             if [ "$SSL" = 'yes' ]; then
-                tpl_file="$WEBTPL/apache_$TPL.stpl"
+                tpl_file="$WEBTPL/apache/$TPL.stpl"
                 conf="$HOMEDIR/$user/conf/web/shttpd.conf"
                 get_web_config_brds
                 sed -n "$top_line,$bottom_line p" $conf > conf/shttpd.conf
@@ -185,14 +185,14 @@ then
 
         # Nginx config
         if [ ! -z "$NGINX" ] ; then
-            tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+            tpl_file="$WEBTPL/nginx/$NGINX.tpl"
             conf="$HOMEDIR/$user/conf/web/nginx.conf"
             get_web_config_brds
             sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf
 
             # SSL check
             if [ "$SSL" = 'yes' ] ; then
-                tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+                tpl_file="$WEBTPL/nginx/$NGINX.stpl"
                 conf="$HOMEDIR/$user/conf/web/snginx.conf"
                 get_web_config_brds
                 sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf

+ 4 - 4
bin/v-change-web-domain-ip

@@ -46,7 +46,7 @@ is_ip_avalable
 # Define variable for replace
 get_domain_values 'web'
 ip=$(get_real_ip $ip)
-tpl_file="$WEBTPL/apache_$TPL.tpl"
+tpl_file="$WEBTPL/apache/$TPL.tpl"
 conf="$HOMEDIR/$user/conf/web/httpd.conf"
 old=$(get_real_ip $IP)
 new=$ip
@@ -54,21 +54,21 @@ replace_web_config
 
 # Checking ssl
 if [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/apache_$TPL.stpl"
+    tpl_file="$WEBTPL/apache/$TPL.stpl"
     conf="$HOMEDIR/$user/conf/web/shttpd.conf"
     replace_web_config
 fi
 
 # Checking nginx
 if [ ! -z "$NGINX" ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.tpl"
     conf="$HOMEDIR/$user/conf/web/nginx.conf"
     replace_web_config
 fi
 
 # Checking nginx
 if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then 
-    tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.stpl"
     conf="$HOMEDIR/$user/conf/web/snginx.conf"
     replace_web_config
 fi

+ 4 - 4
bin/v-change-web-domain-nginx-tpl

@@ -49,7 +49,7 @@ is_nginx_template_valid
 
 # Parsing domain values
 get_domain_values 'web'
-tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+tpl_file="$WEBTPL/nginx/$NGINX.tpl"
 conf="$HOMEDIR/$user/conf/web/nginx.conf"
 ip=$(get_real_ip $IP)
 
@@ -58,7 +58,7 @@ del_web_config
 
 # Checking ssl
 if [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.stpl"
     conf="$HOMEDIR/$user/conf/web/snginx.conf"
     del_web_config
 fi
@@ -66,7 +66,7 @@ fi
 # Add new vhost
 NGINX="$template"
 NGINX_EXT="$extentions"
-tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+tpl_file="$WEBTPL/nginx/$NGINX.tpl"
 conf="$HOMEDIR/$user/conf/web/nginx.conf"
 upd_web_domain_values
 add_web_config
@@ -75,7 +75,7 @@ chmod 640 $conf
 
 # Checking ssl
 if [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.stpl"
     conf="$HOMEDIR/$user/conf/web/snginx.conf"
     add_web_config
     chown root:nginx $conf

+ 3 - 3
bin/v-change-web-domain-sslhome

@@ -39,7 +39,7 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
 get_domain_values 'web'
 old_ssl_home=$SSL_HOME
 SSL_HOME=$ssl_home
-tpl_file="$WEBTPL/apache_$TPL.stpl"
+tpl_file="$WEBTPL/apache/$TPL.stpl"
 conf="$HOMEDIR/$user/conf/web/shttpd.conf"
 
 # Parsing tpl_option
@@ -56,8 +56,8 @@ replace_web_config
 
 # Checking nginx config
 if [ ! -z "$NGINX" ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.stpl"
-    conf="$HOMEDIR/$user/conf/web//snginx.conf"
+    tpl_file="$WEBTPL/nginx/$NGINX.stpl"
+    conf="$HOMEDIR/$user/conf/web/snginx.conf"
     replace_web_config
 fi
 

+ 1 - 1
bin/v-change-web-domain-stats

@@ -63,7 +63,7 @@ rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
 upd_web_domain_values
 
 # Adding statistic config
-cat $WEBTPL/$type.tpl |\
+cat $WEBTPL/$type/$type.tpl |\
     sed -e "s/%ip%/$ip/g" \
         -e "s/%web_port%/$WEB_PORT/g" \
         -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \

+ 8 - 8
bin/v-change-web-domain-tpl

@@ -47,40 +47,40 @@ get_domain_values 'web'
 ip=$(get_real_ip $IP)
 
 # Deleting domain
-tpl_file="$WEBTPL/apache_$TPL.tpl"
+tpl_file="$WEBTPL/apache/$TPL.tpl"
 old_tpl=$TPL
 conf="$HOMEDIR/$user/conf/web/httpd.conf"
 del_web_config
 
 # Deleting ssl vhost
 if [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/apache_$TPL.stpl"
+    tpl_file="$WEBTPL/apache/$TPL.stpl"
     conf="$HOMEDIR/$user/conf/web/shttpd.conf"
     del_web_config
 fi
 
 # Defining variables for new vhost config
 upd_web_domain_values
-tpl_file="$WEBTPL/apache_$template.tpl"
+tpl_file="$WEBTPL/apache/$template.tpl"
 
 # Adding domain to the httpd.conf
 add_web_config
 
 # Running template trigger
-if [ -x $WEBTPL/apache_$template.sh ]; then
-    $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot
+if [ -x $WEBTPL/apache/$template.sh ]; then
+    $WEBTPL/apache/$template.sh $user $domain $ip $HOMEDIR $docroot
 fi
 
 # Checking ssl
 if [ "$SSL" = 'yes' ]; then
     conf="$HOMEDIR/$user/conf/web/shttpd.conf"
-    tpl_file="$WEBTPL/apache_$template.stpl"
+    tpl_file="$WEBTPL/apache/$template.stpl"
 
     add_web_config
 
     # Running template trigger
-    if [ -x $WEBTPL/apache_$template.sh ]; then
-        $WEBTPL/apache_$template.sh \
+    if [ -x $WEBTPL/apache/$template.sh ]; then
+        $WEBTPL/apache/$template.sh \
             "$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot"
     fi
 fi

+ 4 - 4
bin/v-delete-web-domain

@@ -44,7 +44,7 @@ is_object_unsuspended 'web' 'DOMAIN' "$domain"
 
 # Get template name
 get_domain_values 'web'
-tpl_file="$WEBTPL/apache_$TPL.tpl"
+tpl_file="$WEBTPL/apache/$TPL.tpl"
 conf="$HOMEDIR/$user/conf/web/httpd.conf"
 ip=$(get_real_ip $IP)
 
@@ -60,7 +60,7 @@ fi
 
 # Checking ssl
 if [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/apache_$TPL.stpl"
+    tpl_file="$WEBTPL/apache/$TPL.stpl"
     conf="$HOMEDIR/$user/conf/web/shttpd.conf"
     del_web_config
 
@@ -71,12 +71,12 @@ fi
 
 # Checking nginx
 if [ ! -z "$NGINX" ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.tpl"
     conf="$HOMEDIR/$user/conf/web/nginx.conf"
     del_web_config
 
     if [ "$SSL" = 'yes' ]; then
-        tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+        tpl_file="$WEBTPL/nginx/$NGINX.stpl"
         conf="$HOMEDIR/$user/conf/web/snginx.conf"
         del_web_config
     fi

+ 4 - 4
bin/v-delete-web-domain-alias

@@ -55,7 +55,7 @@ ALIAS=$(echo "$ALIAS" |\
     sed -e "s/^$dom_alias$//g"|\
     sed -e "/^$/d"|\
     sed -e ':a;N;$!ba;s/\n/,/g')
-tpl_file="$WEBTPL/apache_$TPL.tpl"
+tpl_file="$WEBTPL/apache/$TPL.tpl"
 conf="$HOMEDIR/$user/conf/web/httpd.conf"
 
 # Preparing domain values for the template substitution
@@ -66,7 +66,7 @@ del_web_config
 add_web_config
 
 if [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/apache_$TPL.stpl"
+    tpl_file="$WEBTPL/apache/$TPL.stpl"
     conf="$HOMEDIR/$user/conf/web/shttpd.conf"
     del_web_config
     add_web_config
@@ -74,13 +74,13 @@ fi
 
 # Checking nginx
 if [ ! -z "$NGINX" ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.tpl"
     conf="$HOMEDIR/$user/conf/web/nginx.conf"
     del_web_config
     add_web_config
 
     if [ "$SSL" = 'yes' ]; then
-        tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+        tpl_file="$WEBTPL/nginx/$NGINX.stpl"
         conf="$HOMEDIR/$user/conf/web/snginx.conf"
         del_web_config
         add_web_config

+ 2 - 2
bin/v-delete-web-domain-nginx

@@ -41,13 +41,13 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX'
 
 # Defining domain parameters
 get_domain_values 'web'
-tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+tpl_file="$WEBTPL/nginx/$NGINX.tpl"
 conf="$HOMEDIR/$user/conf/web/nginx.conf"
 del_web_config
 
 # Checking ssl
 if [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.stpl"
     conf="$HOMEDIR/$user/conf/web/snginx.conf"
     del_web_config
 fi

+ 2 - 2
bin/v-delete-web-domain-ssl

@@ -42,14 +42,14 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
 # Parsing domain values
 get_domain_values 'web'
 conf="$HOMEDIR/$user/conf/web/shttpd.conf"
-tpl_file="$WEBTPL/apache_$TPL.stpl"
+tpl_file="$WEBTPL/apache/$TPL.stpl"
 
 # Deleting domain
 del_web_config
 
 # Checking nginx
 if [ ! -z "$NGINX" ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.stpl"
     conf="$HOMEDIR/$user/conf/web/snginx.conf"
     del_web_config
 fi

+ 2 - 4
bin/v-list-web-templates

@@ -17,8 +17,7 @@ source $VESTA/func/main.sh
 
 # Json function
 json_list_wtpl() {
-    templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\
-        |cut -f 1 -d  '.')
+    templates=$(ls -t $WEBTPL/apache | cut -f 1 -d  '.' |sort -u )
     t_counter=$(echo "$templates" | wc -w)
     i=1
     echo '['
@@ -35,8 +34,7 @@ json_list_wtpl() {
 
 # Shell function
 shell_list_wtpl() {
-    templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\
-        |cut -f 1 -d  '.')
+    templates=$(ls -t $WEBTPL/apache | cut -f 1 -d  '.' |sort -u )
     if [ -z "$nohead" ]; then
         echo "Templates"
         echo "----------"

+ 2 - 4
bin/v-list-web-templates-nginx

@@ -17,8 +17,7 @@ source $VESTA/func/main.sh
 
 # Json function
 json_list_wtpl() {
-    templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\
-        |cut -f 1 -d  '.')
+    templates=$(ls -t $WEBTPL/nginx | cut -f 1 -d  '.' |sort -u )
     t_counter=$(echo "$templates" | wc -w)
     i=1
     echo '['
@@ -35,8 +34,7 @@ json_list_wtpl() {
 
 # Shell function
 shell_list_wtpl() {
-    templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\
-        |cut -f 1 -d  '.')
+    templates=$(ls -t $WEBTPL/nginx | cut -f 1 -d  '.' |sort -u )
     if [ -z "$nohead" ]; then
         echo "Templates"
         echo "----------"

+ 4 - 4
bin/v-suspend-web-domain

@@ -42,7 +42,7 @@ is_object_unsuspended 'web' 'DOMAIN' "$domain"
 
 # Parsing domain values
 get_domain_values 'web'
-tpl_file="$WEBTPL/apache_$TPL.tpl"
+tpl_file="$WEBTPL/apache/$TPL.tpl"
 conf="$HOMEDIR/$user/conf/web/httpd.conf"
 SUSPENDED='yes'
 ip=$(get_real_ip $IP)
@@ -56,7 +56,7 @@ add_web_config
 
 # Check ssl
 if [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/apache_$TPL.stpl"
+    tpl_file="$WEBTPL/apache/$TPL.stpl"
     conf="$HOMEDIR/$user/conf/web/shttpd.conf"
     del_web_config
     add_web_config
@@ -64,13 +64,13 @@ fi
 
 # Checking nginx
 if [ ! -z "$NGINX" ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.tpl"
     conf="$HOMEDIR/$user/conf/web/nginx.conf"
     del_web_config
     add_web_config
 
     if [ "$SSL" = 'yes' ]; then
-        tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+        tpl_file="$WEBTPL/nginx/$NGINX.stpl"
         conf="$HOMEDIR/$user/conf/web/snginx.conf"
         del_web_config
         add_web_config

+ 4 - 4
bin/v-unsuspend-web-domain

@@ -40,7 +40,7 @@ is_object_suspended 'web' 'DOMAIN' "$domain"
 
 # Parsing domain values
 get_domain_values 'web'
-tpl_file="$WEBTPL/apache_$TPL.tpl"
+tpl_file="$WEBTPL/apache/$TPL.tpl"
 conf="$HOMEDIR/$user/conf/web/httpd.conf"
 SUSPENDED='no'
 ip=$(get_real_ip $IP)
@@ -54,7 +54,7 @@ add_web_config
 
 # Check ssl
 if [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/apache_$TPL.stpl"
+    tpl_file="$WEBTPL/apache/$TPL.stpl"
     conf="$HOMEDIR/$user/conf/web/shttpd.conf"
     del_web_config
     add_web_config
@@ -62,13 +62,13 @@ fi
 
 # Checking nginx
 if [ ! -z "$NGINX" ]; then
-    tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+    tpl_file="$WEBTPL/nginx/$NGINX.tpl"
     conf="$HOMEDIR/$user/conf/web/nginx.conf"
     del_web_config
     add_web_config
 
     if [ "$SSL" = 'yes' ]; then
-        tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+        tpl_file="$WEBTPL/nginx/$NGINX.stpl"
         conf="$HOMEDIR/$user/conf/web/snginx.conf"
         del_web_config
         add_web_config

+ 2 - 2
bin/v-update-web-domain-stat

@@ -93,7 +93,7 @@ build_awstats() {
     done
 
     # Creating index page
-    cat $WEBTPL/awstats_index.tpl | sed -e "s/%month%/$month/g" >\
+    cat $WEBTPL/awstats/index.tpl | sed -e "s/%month%/$month/g" >\
         $dir/index.html
 
     # Creating navigation page
@@ -120,7 +120,7 @@ build_awstats() {
 
         select_m="$select_m<option value=$link>$month $year<\/option>\n"
     done
-    cat $WEBTPL/awstats_nav.tpl | sed -e "s/%select_month%/$select_m/" >\
+    cat $WEBTPL/awstats/nav.tpl | sed -e "s/%select_month%/$select_m/" >\
         $dir/nav.html
 }
 

+ 11 - 11
func/domain.sh

@@ -1,11 +1,11 @@
 # Web template check
 is_apache_template_valid() {
-    t="$WEBTPL/apache_$template.tpl"
-    s="$WEBTPL/apache_$template.stpl"
+    t="$WEBTPL/apache/$template.tpl"
+    s="$WEBTPL/apache/$template.stpl"
     if [ ! -e $t ] || [ ! -e $s ]; then
         template='default'
-        t="$WEBTPL/apache_$template.tpl"
-        s="$WEBTPL/apache_$template.stpl"
+        t="$WEBTPL/apache/$template.tpl"
+        s="$WEBTPL/apache/$template.stpl"
         if [ ! -e $t ] || [ ! -e $s ]; then
             echo "Error: template $template not found"
             log_event "$E_NOTEXIST" "$EVENT"
@@ -16,12 +16,12 @@ is_apache_template_valid() {
 
 # Nginx template check
 is_nginx_template_valid() {
-    t="$WEBTPL/nginx_$template.tpl"
-    s="$WEBTPL/nginx_$template.stpl"
+    t="$WEBTPL/nginx/$template.tpl"
+    s="$WEBTPL/nginx/$template.stpl"
     if [ ! -e $t ] || [ ! -e $s ]; then
         template='default'
-        t="$WEBTPL/nginx_$template.tpl"
-        s="$WEBTPL/nginx_$template.stpl"
+        t="$WEBTPL/nginx/$template.tpl"
+        s="$WEBTPL/nginx/$template.stpl"
         if [ ! -e $t ] || [ ! -e $s ]; then
             echo "Error: nginx $template not found"
             log_event "$E_NOTEXIST" "$EVENT"
@@ -416,7 +416,7 @@ namehost_ip_support() {
         sed -i "$conf_ins i Listen $ip:$WEB_PORT" $conf
 
         if [ "$PROXY_SYSTEM" = 'nginx' ]; then
-            cat $WEBTPL/ngingx.ip.tpl | sed -e "s/%ip%/$ip/g" \
+            cat $WEBTPL/nginx/ip.tpl | sed -e "s/%ip%/$ip/g" \
              -e "s/%web_port%/$WEB_PORT/g" \
             -e "s/%proxy_port%/$PROXY_PORT/g" >>$nconf
 
@@ -434,8 +434,8 @@ namehost_ip_disable() {
         sed -i "/Listen $ip:/d" $conf
 
         if [ "$PROXY_SYSTEM" = 'nginx' ]; then
-            tpl_ln=$(wc -l $WEBTPL/ngingx.ip.tpl | cut -f 1 -d ' ')
-            ip_line=$(grep -n "%ip%" $WEBTPL/ngingx.ip.tpl |head -n1 |\
+            tpl_ln=$(wc -l $WEBTPL/nginx/ip.tpl | cut -f 1 -d ' ')
+            ip_line=$(grep -n "%ip%" $WEBTPL/nginx/ip.tpl |head -n1 |\
                 cut -f 1 -d :)
             conf_line=$(grep -n -w $ip $nconf|head -n1|cut -f 1 -d :)
             if [ -z "$tpl_ln" ] || [ -z "$ip_line" ] || [ -z "$conf_line" ]

+ 9 - 9
func/rebuild.sh

@@ -190,15 +190,15 @@ rebuild_web_domain_conf() {
 
 
     # Adding tmp_httpd.conf
-    tpl_file="$WEBTPL/apache_$TPL.tpl"
+    tpl_file="$WEBTPL/apache/$TPL.tpl"
     conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf"
     add_web_config
     chown root:apache $conf
     chmod 640 $conf
 
     # Running template trigger
-    if [ -x $WEBTPL/apache_$TPL.sh ]; then
-        $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot
+    if [ -x $WEBTPL/apache/$TPL.sh ]; then
+        $WEBTPL/apache/$TPL.sh $user $domain $ip $HOMEDIR $docroot
     fi
 
     # Checking aliases
@@ -209,7 +209,7 @@ rebuild_web_domain_conf() {
 
     # Checking stats
     if [ ! -z "$STATS" ]; then
-        cat $WEBTPL/$STATS.tpl |\
+        cat $WEBTPL/$STATS/$STATS.tpl |\
             sed -e "s/%ip%/$ip/g" \
                 -e "s/%web_port%/$WEB_PORT/g" \
                 -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
@@ -254,7 +254,7 @@ rebuild_web_domain_conf() {
     if [ "$SSL" = 'yes' ]; then
         # Adding domain to the shttpd.conf
         conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf"
-        tpl_file="$WEBTPL/apache_$TPL.stpl"
+        tpl_file="$WEBTPL/apache/$TPL.stpl"
         add_web_config
         chown root:apache $conf
         chmod 640 $conf
@@ -271,8 +271,8 @@ rebuild_web_domain_conf() {
         fi
 
         # Running template trigger
-        if [ -x $WEBTPL/apache_$TPL.sh ]; then
-            $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $sdocroot
+        if [ -x $WEBTPL/apache/$TPL.sh ]; then
+            $WEBTPL/apache/$TPL.sh $user $domain $ip $HOMEDIR $sdocroot
         fi
 
         user_ssl=$((user_ssl + 1))
@@ -281,14 +281,14 @@ rebuild_web_domain_conf() {
 
     # Checking nginx
     if [ ! -z "$NGINX" ]; then
-        tpl_file="$WEBTPL/nginx_$NGINX.tpl"
+        tpl_file="$WEBTPL/nginx/$NGINX.tpl"
         conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf"
         add_web_config
         chown root:nginx $conf
         chmod 640 $conf
 
         if [ "$SSL" = 'yes' ]; then
-            tpl_file="$WEBTPL/nginx_$NGINX.stpl"
+            tpl_file="$WEBTPL/nginx/$NGINX.stpl"
             conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf"
             add_web_config
             chown root:nginx $conf

+ 51 - 0
upd/convert-templates.sh

@@ -0,0 +1,51 @@
+#!/bin/bash
+
+# Define data path
+TPL='/usr/local/vesta/data/templates/web'
+
+# Check for new template structure
+if [ -e "$TPL/apache" ]; then
+    exit
+fi
+
+# Remove unused email template
+rm -f $TPL/email_reset_password.tpl
+
+# Apache
+mkdir -p $TPL/apache
+if [ ! -z "$(ls $TPL/| grep apache_)" ];then
+    mv $TPL/apache_* $TPL/apache/
+    for template in $(ls $TPL/apache/); do
+        new_name=$(echo $template |sed -e "s/apache_//")
+        mv -f $TPL/apache/$template $TPL/apache/$new_name
+    done
+fi
+
+# Nginx
+mkdir -p $TPL/nginx
+if [ ! -z "$(ls $TPL/| grep nginx_)" ];then
+    mv $TPL/nginx_* $TPL/nginx/
+    for template in $(ls $TPL/nginx/); do
+        new_name=$(echo $template |sed -e "s/nginx_//")
+        mv -f $TPL/nginx/$template $TPL/nginx/$new_name
+    done
+fi
+if [ -e "$TPL/ngingx.ip.tpl" ]; then
+    mv $TPL/ngingx.ip.tpl $TPL/nginx/ip.tpl
+fi
+
+# Awstats
+mkdir -p $TPL/awstats
+if [ -e "$TPL/awstats.tpl" ]; then
+    mv $TPL/awstats.tpl $TPL/awstats
+    mv $TPL/awstats_index.tpl $TPL/awstats/index.tpl
+    mv $TPL/awstats_nav.tpl $TPL/awstats/nav.tpl
+fi
+
+# Webalizer
+mkdir -p $TPL/webalizer
+if [ -e "$TPL/webalizer.tpl" ]; then
+    mv $TPL/webalizer.tpl $TPL/webalizer
+fi
+
+exit