Przeglądaj źródła

extended %elog% support

Serghey Rodin 14 lat temu
rodzic
commit
0b5cf52114

+ 16 - 4
bin/v_add_web_domain

@@ -81,13 +81,26 @@ else
 fi
 
 # Defining vars for httpd_add_config function
-port=$(get_config_value '$WEB_PORT')
+web_port=$(get_config_value '$WEB_PORT')
 group="$user"
 email="$user@$domain"
 docroot="$V_HOME/$user/domains/$domain/public_html"
 conf="$V_HOME/$user/conf/httpd.conf"
 tpl_file="$V_WEBTPL/apache_$template.tpl"
 
+# Parsing template keys
+template_data=$(cat $V_WEBTPL/apache_$template.descr|grep -v '#')
+for keys in $template_data; do
+    eval ${keys%%=*}=${keys#*=}
+done
+
+# Checking error log status
+if [ "$ELOG" = 'no' ]; then
+    elog=' #'
+else
+    elog=' '
+fi
+
 # Adding domain to the httpd.conf
 httpd_add_config
 
@@ -139,8 +152,8 @@ chmod 551 $V_HOME/$user/domains/$domain/logs
 chmod 640 /var/log/httpd/domains/$domain.*
 
 # Running template trigger
-if [ -e $V_WEBTPL/apache_$template.sh ]; then
-    $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot $port
+if [ -x $V_WEBTPL/apache_$template.sh ]; then
+    $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot
 fi
 
 # Checking main vesta httpd config
@@ -162,7 +175,6 @@ increase_ip_value
 increase_user_value "$user" '$U_WEB_DOMAINS'
 
 # Defining domain variables
-template_data=$(cat $V_WEBTPL/apache_$template.descr|grep -v '#')
 v_str="DOMAIN='$domain'"
 v_str="$v_str IP='$ip'"
 v_str="$v_str U_DISK='0'"

+ 11 - 3
bin/v_add_web_domain_ssl

@@ -68,7 +68,7 @@ is_template_valid 'web'
 #----------------------------------------------------------#
 
 # Defining variables for template replace
-port=$(get_config_value '$WEB_SSL_PORT')
+web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
 aliases=$(get_web_domain_value '$ALIAS')
 aliases_idn=$(idn -t --quiet -a "$aliases")
 email="$user@$domain"
@@ -83,6 +83,14 @@ group="$user"
 conf="$V_HOME/$user/conf/shttpd.conf"
 tpl_file="$V_WEBTPL/apache_$template.stpl"
 
+# Checking error log status
+elog=$(get_web_domain_value '$ELOG')
+if [ "$elog" = 'no' ]; then
+    elog=' #'
+else
+    elog=' '
+fi
+
 # Adding domain to the httpd.conf
 httpd_add_config
 
@@ -93,8 +101,8 @@ if [ ! -e "$ssl_cert" ]; then
 fi
 
 # Running template trigger
-if [ -e $V_WEBTPL/apache_$template.sh ]; then
-    $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot $port
+if [ -x $V_WEBTPL/apache_$template.sh ]; then
+    $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot
 fi
 
 # Checking main vesta httpd config

+ 24 - 9
bin/v_change_web_domain_tpl

@@ -7,7 +7,8 @@
 
 # Argument defenition
 user="$1"
-domain="$2"
+domain=$(idn -t --quiet -u "$2" )
+domain_idn=$(idn -t --quiet -a "$domain")
 template="$3"
 
 # Importing variables
@@ -73,25 +74,39 @@ fi
 # Defining variables for template replace
 ip=$(get_web_domain_value '$IP')
 aliases=$(get_web_domain_value '$ALIAS')
-port=$(get_config_value '$WEB_PORT')
+aliases_idn=$(idn -t --quiet -a "$aliases")
+web_port=$(get_config_value '$WEB_PORT')
 email="$user@$domain"
 docroot="$V_HOME/$user/domains/$domain/public_html"
 conf="$V_HOME/$user/conf/httpd.conf"
 tpl_file="$V_WEBTPL/apache_$template.tpl"
 group="$user"
 
+# Parsing template keys
+template_data=$(cat $V_WEBTPL/apache_$template.descr|grep -v '#')
+for keys in $template_data; do
+    eval ${keys%%=*}=${keys#*=}
+done
+
+# Checking error log status
+if [ "$ELOG" = 'no' ]; then
+    elog=' #'
+else
+    elog=' '
+fi
+
 # Adding domain to the httpd.conf
 httpd_add_config
 
-# Running template post setup file
-if [ -e $V_WEBTPL/apache_$template.sh ]; then
-    $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot $port
+# Running template trigger
+if [ -x $V_WEBTPL/apache_$template.sh ]; then
+    $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot
 fi
 
 # Checking ssl
 if [ "$ssl" = 'yes' ]; then
     # Defining variables for ssl template replace
-    port=$(get_config_value '$WEB_SSL_PORT')
+    web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
     tpl_option=$(get_web_domain_value '$SSL_HOME')
     cert=$(get_web_domain_value '$SSL_CERT')
     ssl_cert="$V_HOME/$user/conf/$cert.crt"
@@ -106,10 +121,10 @@ if [ "$ssl" = 'yes' ]; then
     # Adding domain to the httpd.conf
     httpd_add_config
 
-    # Running template post setup file
-    if [ -e $V_WEBTPL/apache_$template.sh ]; then
+    # Running template trigger
+    if [ -x $V_WEBTPL/apache_$template.sh ]; then
         $V_WEBTPL/apache_$template.sh \
-            "$user" "$domain" "$ip" "$V_HOME" "$docroot" "$port"
+            "$user" "$domain" "$ip" "$V_HOME" "$docroot"
     fi
 fi
 

+ 13 - 5
bin/v_rebuild_web_domains

@@ -58,7 +58,7 @@ for domain in $domains; do
     template=$(get_web_domain_value '$TPL')
     tpl_file="$V_WEBTPL/apache_$template.tpl"
     ip=$(get_web_domain_value '$IP')
-    port=$(get_config_value '$WEB_PORT')
+    web_port=$(get_config_value '$WEB_PORT')
     domain=$(get_web_domain_value '$DOMAIN')
     domain_idn=$(idn -t --quiet -a "$domain")
     group="$user"
@@ -67,13 +67,21 @@ for domain in $domains; do
     aliases=$(get_web_domain_value '$ALIAS')
     aliases_idn=$(idn -t --quiet -a "$aliases")
 
+    # Checking error log status
+    elog=$(get_web_domain_value '$ELOG')
+    if [ "$elog" = 'no' ]; then
+        elog=' #'
+    else
+        elog=' '
+    fi
+
     # Adding domain to the tmp_httpd.conf
     conf="$V_HOME/$user/conf/tmp_httpd.conf"
     httpd_add_config
 
     # Running template trigger
     if [ -x $V_WEBTPL/apache_$template.sh ]; then
-        $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot $port
+        $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot
     fi
 
     # Checking ssl
@@ -89,16 +97,16 @@ for domain in $domains; do
             same) docroot="$V_HOME/$user/domains/$domain/public_html" ;;
             *) check_args '3' "$#" 'user domain certificate [sslhome]'
         esac
-        port=$(get_config_value '$WEB_SSL_PORT')
+        web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
 
         # Adding domain to the httpd.conf
         conf="$V_HOME/$user/conf/tmp_shttpd.conf"
         tpl_file="$V_WEBTPL/apache_$template.stpl"
         httpd_add_config
 
+        # Running template trigger
         if [ -x $V_WEBTPL/apache_$template.sh ]; then
-            $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME \
-                $docroot $port
+            $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot
         fi
     fi
 done