Procházet zdrojové kódy

Added web tab triggers. Issue #50

Serghey Rodin před 14 roky
rodič
revize
3a09991f0a

+ 1 - 0
bin/v_add_web_domain

@@ -207,6 +207,7 @@ increase_ip_value "$ip"
 
 # Increasing domain value
 increase_user_value "$user" '$U_WEB_DOMAINS'
+increase_user_value "$user" '$U_WEB_ALIASES'
 
 # Defining domain variables
 v_str="DOMAIN='$domain'"

+ 3 - 0
bin/v_add_web_domain_alias

@@ -120,6 +120,9 @@ fi
 # Adding new alias
 update_web_domain_value '$ALIAS' "$ALIAS"
 
+# Update counters
+increase_user_value "$user" '$U_WEB_ALIASES'
+
 # Adding task to the vesta pipe
 restart_schedule 'web'
 

+ 15 - 0
bin/v_delete_web_domain

@@ -63,6 +63,13 @@ conf="$V_HOME/$user/conf/web/httpd.conf"
 # Deleting domain
 del_web_config
 
+# Checking aliases
+if [ ! -z "$ALIAS" ]; then
+    aliases=$(echo $ALIAS | tr ',' '\n' | wc -l )
+else
+    aliases=0
+fi
+
 # Checking ssl
 if [ "$SSL" = 'yes' ]; then
     tpl_file="$V_WEBTPL/apache_$TPL.stpl"
@@ -152,6 +159,14 @@ decrease_ip_value "$IP"
 # Decreasing domain value
 decrease_user_value "$user" '$U_WEB_DOMAINS'
 
+# Decreasing web aliases
+decrease_user_value "$user" '$U_WEB_ALIASES' "$aliases"
+
+# Decreasing web ssl
+if [ "$SSL" = 'yes' ]; then
+    decrease_user_value "$user" '$U_WEB_SSL'
+fi
+
 # Adding task to the vesta pipe
 restart_schedule 'web'
 

+ 3 - 0
bin/v_delete_web_domain_alias

@@ -109,6 +109,9 @@ fi
 # Deleting alias
 update_web_domain_value '$ALIAS' "$ALIAS"
 
+# Update counters
+decrease_user_value "$user" '$U_WEB_ALIASES'
+
 # Adding task to the vesta pipe
 restart_schedule 'web'
 

+ 1 - 1
bin/v_list_web_domains_alias

@@ -48,7 +48,7 @@ fields="\$DOMAIN \$ALIAS"
 case $format in 
     json)   json_list ;;
     plain)  nohead=1; shell_list ;;
-    shell)  shell_list | column -t ;;
+    shell)  shell_list;;
     *)      check_args '1' '0' 'user [format]'
 esac
 

+ 1 - 0
bin/v_suspend_web_domain

@@ -97,6 +97,7 @@ fi
 
 # Adding suspend in config
 update_web_domain_value '$SUSPENDED' 'yes'
+increase_user_value "$user" '$SUSPENDED_WEB'
 
 # Adding task to the vesta pipe
 restart_schedule 'web'

+ 2 - 1
bin/v_unsuspend_web_domain

@@ -90,8 +90,9 @@ fi
 #                       Vesta                              #
 #----------------------------------------------------------#
 
-# Adding suspend in config
+# Updating suspend keys
 update_web_domain_value '$SUSPENDED' 'no'
+decrease_user_value "$user" '$SUSPENDED_WEB'
 
 # Adding task to the vesta pipe
 restart_schedule 'web'

+ 4 - 2
func/shared.func

@@ -692,6 +692,7 @@ update_user_value() {
 increase_user_value() {
     USER="$1"
     key="${2//$}"
+    factor="${3-1}"
 
     # Parsing current value
     conf="$V_USERS/$USER/user.conf"
@@ -701,7 +702,7 @@ increase_user_value() {
     fi
 
     # Increasing
-    new=$((old + 1 ))
+    new=$((old + factor))
     sed -i "s/$key='$old'/$key='$new'/g" $conf
 }
 
@@ -731,6 +732,7 @@ is_type_valid() {
 decrease_user_value() {
     USER="$1"
     key="${2//$}"
+    factor="${3-1}"
 
     # Parsing current value
     conf="$V_USERS/$USER/user.conf"
@@ -743,7 +745,7 @@ decrease_user_value() {
     if [ "$old" -le 1 ]; then
         new=0
     else
-        new=$((old - 1 ))
+        new=$((old - factor))
     fi
     sed -i "s/$key='$old'/$key='$new'/g" $conf
 }