Explorar o código

check_result function

Serghey Rodin %!s(int64=10) %!d(string=hai) anos
pai
achega
91a804c1c8
Modificáronse 66 ficheiros con 204 adicións e 404 borrados
  1. 2 4
      bin/v-add-cron-job
  2. 1 3
      bin/v-add-cron-reports
  3. 2 4
      bin/v-add-cron-vesta-autoupdate
  4. 2 6
      bin/v-add-sys-ip
  5. 3 14
      bin/v-add-sys-quota
  6. 1 5
      bin/v-add-user
  7. 4 7
      bin/v-add-web-domain
  8. 6 8
      bin/v-add-web-domain-alias
  9. 1 3
      bin/v-add-web-domain-backend
  10. 2 4
      bin/v-add-web-domain-proxy
  11. 6 8
      bin/v-add-web-domain-ssl
  12. 2 4
      bin/v-change-cron-job
  13. 2 4
      bin/v-change-dns-domain-ip
  14. 2 4
      bin/v-change-dns-domain-soa
  15. 2 4
      bin/v-change-dns-domain-tpl
  16. 2 4
      bin/v-change-dns-domain-ttl
  17. 2 4
      bin/v-change-dns-record
  18. 2 4
      bin/v-change-dns-record-id
  19. 1 3
      bin/v-change-sys-ip-nat
  20. 4 7
      bin/v-change-web-domain-backend-tpl
  21. 11 13
      bin/v-change-web-domain-ip
  22. 3 5
      bin/v-change-web-domain-proxy-tpl
  23. 11 10
      bin/v-change-web-domain-sslcert
  24. 11 10
      bin/v-change-web-domain-sslhome
  25. 2 4
      bin/v-change-web-domain-tpl
  26. 2 4
      bin/v-delete-cron-job
  27. 2 4
      bin/v-delete-cron-reports
  28. 2 4
      bin/v-delete-cron-vesta-autoupdate
  29. 2 4
      bin/v-delete-dns-domain
  30. 5 4
      bin/v-delete-dns-domains
  31. 1 3
      bin/v-delete-dns-domains-src
  32. 2 4
      bin/v-delete-dns-record
  33. 2 6
      bin/v-delete-sys-ip
  34. 3 7
      bin/v-delete-web-domain
  35. 6 8
      bin/v-delete-web-domain-alias
  36. 2 4
      bin/v-delete-web-domain-backend
  37. 1 3
      bin/v-delete-web-domain-proxy
  38. 6 8
      bin/v-delete-web-domain-ssl
  39. 3 7
      bin/v-delete-web-domains
  40. 2 4
      bin/v-insert-dns-domain
  41. 2 4
      bin/v-insert-dns-record
  42. 2 4
      bin/v-insert-dns-records
  43. 2 4
      bin/v-rebuild-cron-jobs
  44. 2 4
      bin/v-rebuild-dns-domain
  45. 2 4
      bin/v-rebuild-dns-domains
  46. 4 8
      bin/v-rebuild-web-domains
  47. 2 6
      bin/v-start-service
  48. 2 6
      bin/v-stop-service
  49. 2 4
      bin/v-suspend-cron-job
  50. 2 4
      bin/v-suspend-cron-jobs
  51. 0 8
      bin/v-suspend-dns-domain
  52. 0 8
      bin/v-suspend-dns-domains
  53. 0 8
      bin/v-suspend-dns-record
  54. 4 10
      bin/v-suspend-user
  55. 14 16
      bin/v-suspend-web-domain
  56. 5 7
      bin/v-suspend-web-domains
  57. 2 4
      bin/v-unsuspend-cron-job
  58. 2 4
      bin/v-unsuspend-cron-jobs
  59. 0 9
      bin/v-unsuspend-dns-domain
  60. 0 8
      bin/v-unsuspend-dns-domains
  61. 0 8
      bin/v-unsuspend-dns-record
  62. 4 9
      bin/v-unsuspend-user
  63. 15 17
      bin/v-unsuspend-web-domain
  64. 5 7
      bin/v-unsuspend-web-domains
  65. 1 3
      bin/v-update-sys-ip
  66. 2 10
      bin/v-update-sys-vesta

+ 2 - 4
bin/v-add-cron-job

@@ -72,11 +72,9 @@ sync_cron_jobs
 # Increasing cron value
 # Increasing cron value
 increase_user_value $user '$U_CRON_JOBS'
 increase_user_value $user '$U_CRON_JOBS'
 
 
-# Restart crond
+# Restarting crond
 $BIN/v-restart-cron
 $BIN/v-restart-cron
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Cron restart failed" >/dev/null
 
 
 # Logging
 # Logging
 log_history "added cron job $job"
 log_history "added cron job $job"

+ 1 - 3
bin/v-add-cron-reports

@@ -46,9 +46,7 @@ sync_cron_jobs
 
 
 # Restart crond
 # Restart crond
 $BIN/v-restart-cron
 $BIN/v-restart-cron
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Cron restart failed" >/dev/null
 
 
 # Logging
 # Logging
 log_history "enabled cron reporting"
 log_history "enabled cron reporting"

+ 2 - 4
bin/v-add-cron-vesta-autoupdate

@@ -66,11 +66,9 @@ sync_cron_jobs
 # Increasing cron value
 # Increasing cron value
 increase_user_value $user '$U_CRON_JOBS'
 increase_user_value $user '$U_CRON_JOBS'
 
 
-# Restart crond
+# Restarting crond
 $BIN/v-restart-cron
 $BIN/v-restart-cron
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Cron restart failed" >/dev/null
 
 
 # Logging
 # Logging
 log_history "added cron job $job"
 log_history "added cron job $job"

+ 2 - 6
bin/v-add-sys-ip

@@ -161,16 +161,12 @@ fi
 
 
 # Restarting web server
 # Restarting web server
 $BIN/v-restart-web
 $BIN/v-restart-web
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Web restart failed" >/dev/null
 
 
 # Restarting proxy server
 # Restarting proxy server
 if [ ! -z "$PROXY_SYSTEM" ]; then
 if [ ! -z "$PROXY_SYSTEM" ]; then
     $BIN/v-restart-proxy
     $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Proxy restart failed" >/dev/null
 fi
 fi
 
 
 # Restarting firewall
 # Restarting firewall

+ 3 - 14
bin/v-add-sys-quota

@@ -22,18 +22,11 @@ source $VESTA/conf/vesta.conf
 if [ ! -e "/usr/sbin/setquota" ]; then
 if [ ! -e "/usr/sbin/setquota" ]; then
     if [ -e "/etc/redhat-release" ]; then
     if [ -e "/etc/redhat-release" ]; then
         yum -y install quota >/dev/null 2>&1
         yum -y install quota >/dev/null 2>&1
-        result=$?
+        check_result $? "quota package installation failed" $E_UPDATE
     else
     else
         export DEBIAN_FRONTEND=noninteractive
         export DEBIAN_FRONTEND=noninteractive
         apt-get -y install quota >/dev/null 2>&1
         apt-get -y install quota >/dev/null 2>&1
-        result=$?
-    fi
-
-    # Checking installation status
-    if [ "$result" -ne 0 ]; then
-        echo "Error: quota package wasn't successfully installed"
-        log_event "$E_UPDATE" "$EVENT"
-        exit $E_UPDATE
+        check_result $? "quota package installation failed" $E_UPDATE
     fi
     fi
 fi
 fi
 
 
@@ -66,11 +59,7 @@ chmod a+x /etc/cron.daily/quotacheck
 # Enabling fs quota
 # Enabling fs quota
 if [ ! -z "$(quotaon -pa|grep " $mnt "|grep user|grep 'off')" ]; then
 if [ ! -z "$(quotaon -pa|grep " $mnt "|grep user|grep 'off')" ]; then
     quotaon $mnt
     quotaon $mnt
-    if [ $? -ne 0 ]; then
-        echo "Error: quota can't be enabled on $mnt partition"
-        log_event "$E_DISK" "$EVENT"
-        exit $E_DISK
-    fi
+    check_result $? "quota can't be enabled in $mtn" $E_DISK
 fi
 fi
 
 
 # Updating DISK_QUOTA value
 # Updating DISK_QUOTA value

+ 1 - 5
bin/v-add-user

@@ -58,11 +58,7 @@ shell=$(grep -w "$shell_conf" /etc/shells |head -n1)
 
 
 # Adding user
 # Adding user
 /usr/sbin/useradd "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user"
 /usr/sbin/useradd "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user"
-if [ $? -ne 0 ]; then
-    echo "Error: user creation failed"
-    log_event "$E_INVALID" "$EVENT"
-    exit $E_INVALID
-fi
+check_result $? "user creation failed" $E_INVALID
 
 
 # Adding password
 # Adding password
 echo "$user:$password" | /usr/sbin/chpasswd
 echo "$user:$password" | /usr/sbin/chpasswd

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

@@ -213,17 +213,14 @@ str="$str TIME='$TIME' DATE='$DATE'"
 # Registering domain
 # Registering domain
 echo "$str" >> $USER_DATA/web.conf
 echo "$str" >> $USER_DATA/web.conf
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
+
     if [ ! -z "$PROXY_SYSTEM" ]; then
     if [ ! -z "$PROXY_SYSTEM" ]; then
         $BIN/v-restart-proxy
         $BIN/v-restart-proxy
-        if [ $? -ne 0 ]; then
-            exit $E_RESTART
-        fi
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 6 - 8
bin/v-add-web-domain-alias

@@ -75,7 +75,7 @@ if [ "$SSL" = 'yes' ]; then
 fi
 fi
 
 
 # Checking proxy
 # Checking proxy
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     del_web_config
     del_web_config
@@ -100,16 +100,14 @@ update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
 # Update counters
 # Update counters
 increase_user_value "$user" '$U_WEB_ALIASES'
 increase_user_value "$user" '$U_WEB_ALIASES'
 
 
-# Adding task to the vesta pipe
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

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

@@ -67,9 +67,7 @@ cat $WEBTPL/$WEB_BACKEND/$template.tpl |\
 # Restart backend server
 # Restart backend server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web-backend
     $BIN/v-restart-web-backend
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web backend restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-add-web-domain-proxy

@@ -100,12 +100,10 @@ fi
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-proxy
     $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Proxy restart failed" >/dev/null
 fi
 fi
 
 
 log_history "enabled proxy support for $domain"
 log_history "enabled proxy support for $domain"

+ 6 - 8
bin/v-add-web-domain-ssl

@@ -97,7 +97,7 @@ if [ -z "$(grep "$conf" $web_conf)" ]; then
 fi
 fi
 
 
 # Checking proxy
 # Checking proxy
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
     add_web_config
     add_web_config
@@ -124,16 +124,14 @@ increase_user_value "$user" '$U_WEB_SSL'
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes"
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes"
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 2 - 4
bin/v-change-cron-job

@@ -64,11 +64,9 @@ sync_cron_jobs
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart crond
+# Restarting crond
 $BIN/v-restart-cron
 $BIN/v-restart-cron
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Cron restart failed" >/dev/null
 
 
 # Logging
 # Logging
 log_history "changed cron job $job"
 log_history "changed cron job $job"

+ 2 - 4
bin/v-change-dns-domain-ip

@@ -70,12 +70,10 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-change-dns-domain-soa

@@ -64,12 +64,10 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-change-dns-domain-tpl

@@ -90,12 +90,10 @@ fi
 update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
 update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
 update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
 update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-change-dns-domain-ttl

@@ -63,12 +63,10 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-change-dns-record

@@ -96,12 +96,10 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-change-dns-record-id

@@ -70,12 +70,10 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 1 - 3
bin/v-change-sys-ip-nat

@@ -77,9 +77,7 @@ fi
 # Restart ftp server
 # Restart ftp server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-ftp
     $BIN/v-restart-ftp
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "FTP restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 4 - 7
bin/v-change-web-domain-backend-tpl

@@ -155,16 +155,13 @@ fi
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 
 
-# Restart web
+# Restarting web
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
+
     $BIN/v-restart-web-backend
     $BIN/v-restart-web-backend
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web backend restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 11 - 13
bin/v-change-web-domain-ip

@@ -59,17 +59,17 @@ if [ "$SSL" = 'yes' ]; then
 fi
 fi
 
 
 # Checking proxy
 # Checking proxy
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     replace_web_config
     replace_web_config
-fi
 
 
-# Checking SSL proxy
-if [ "$SSL" = 'yes' ] && [ ! -z "$PROXY" ]; then 
-    tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
-    conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
-    replace_web_config
+    # Checking SSL proxy
+    if [ "$SSL" = 'yes' ] && [ ! -z "$PROXY" ]; then 
+        tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
+        conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
+        replace_web_config
+    fi
 fi
 fi
 
 
 
 
@@ -87,13 +87,11 @@ update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$3"
 # Restart web server
 # Restart web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "WEB restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 3 - 5
bin/v-change-web-domain-proxy-tpl

@@ -87,16 +87,14 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Update config
+# Updating config
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
 
 
-# Restart web
+# Restarting proxy
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-proxy
     $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Proxy restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 11 - 10
bin/v-change-web-domain-sslcert

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 # info: change domain ssl certificate
 # info: change domain ssl certificate
-# options: USER DOMAIN SSL_DIR
+# options: USER DOMAIN SSL_DIR [RESTART]
 #
 #
 # The function changes SSL domain certificate and the key. If ca file present
 # The function changes SSL domain certificate and the key. If ca file present
 # it will be replaced as well.
 # it will be replaced as well.
@@ -15,6 +15,7 @@ user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
 ssl_dir=$3
 ssl_dir=$3
+restart=$4
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
@@ -26,7 +27,7 @@ source $VESTA/conf/vesta.conf
 #                    Verifications                         #
 #                    Verifications                         #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-check_args '3' "$#" 'USER DOMAIN SSL_DIR'
+check_args '3' "$#" 'USER DOMAIN SSL_DIR [RESTART]'
 validate_format 'user' 'domain' 'ssl_dir'
 validate_format 'user' 'domain' 'ssl_dir'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
@@ -69,15 +70,15 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart web server
-$BIN/v-restart-web
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+# Restarting web server
+if [ "$restart" != 'no' ]; then
+    $BIN/v-restart-web
+    check_result $? "Web restart failed" >/dev/null
 
 
-$BIN/v-restart-proxy
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
+    fi
 fi
 fi
 
 
 # Logging
 # Logging

+ 11 - 10
bin/v-change-web-domain-sslhome

@@ -10,6 +10,7 @@ user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
 ssl_home=$3
 ssl_home=$3
+restart=$4
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
@@ -21,7 +22,7 @@ source $VESTA/conf/vesta.conf
 #                    Verifications                         #
 #                    Verifications                         #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-check_args '3' "$#" 'USER DOMAIN SSL_HOME'
+check_args '3' "$#" 'USER DOMAIN SSL_HOME [RESTART]'
 validate_format 'user' 'domain'
 validate_format 'user' 'domain'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
@@ -55,7 +56,7 @@ esac
 replace_web_config
 replace_web_config
 
 
 # Checking proxy config
 # Checking proxy config
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
     conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
     replace_web_config
     replace_web_config
@@ -69,15 +70,15 @@ fi
 # Update config
 # Update config
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
 
 
-# Restart web server
-$BIN/v-restart-web
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+# Restarting web server
+if [ "$restart" != 'no' ]; then
+    $BIN/v-restart-web
+    check_result $? "Web restart failed" >/dev/null
 
 
-$BIN/v-restart-proxy
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
+    fi
 fi
 fi
 
 
 # Logging
 # Logging

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

@@ -93,12 +93,10 @@ fi
 # Changing tpl in config
 # Changing tpl in config
 update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template"
 update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template"
 
 
-# Restart web
+# Restarting web
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-delete-cron-job

@@ -52,11 +52,9 @@ sync_cron_jobs
 # Decreasing cron value
 # Decreasing cron value
 decrease_user_value "$user" '$U_CRON_JOBS'
 decrease_user_value "$user" '$U_CRON_JOBS'
 
 
-# Restart crond
+# Restarting crond
 $BIN/v-restart-cron
 $BIN/v-restart-cron
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Restart restart failed" >/dev/null
 
 
 # Logging
 # Logging
 log_history "deleted cron job $job"
 log_history "deleted cron job $job"

+ 2 - 4
bin/v-delete-cron-reports

@@ -44,11 +44,9 @@ sync_cron_jobs
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart crond
+# Restarting crond
 $BIN/v-restart-cron
 $BIN/v-restart-cron
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Cron restart failed" >/dev/null
 
 
 # Logging
 # Logging
 log_history "disabled cron reporting"
 log_history "disabled cron reporting"

+ 2 - 4
bin/v-delete-cron-vesta-autoupdate

@@ -51,11 +51,9 @@ sync_cron_jobs
 # Decreasing cron value
 # Decreasing cron value
 decrease_user_value "$user" '$U_CRON_JOBS'
 decrease_user_value "$user" '$U_CRON_JOBS'
 
 
-# Restart crond
+# Restarting crond
 $BIN/v-restart-cron
 $BIN/v-restart-cron
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Cron restart failed" >/dev/null
 
 
 # Logging
 # Logging
 log_event "$OK" "$EVENT"
 log_event "$OK" "$EVENT"

+ 2 - 4
bin/v-delete-dns-domain

@@ -71,12 +71,10 @@ rm -f $USER_DATA/dns/$domain.conf
 decrease_user_value "$user" '$U_DNS_DOMAINS'
 decrease_user_value "$user" '$U_DNS_DOMAINS'
 decrease_user_value "$user" '$U_DNS_RECORDS' "$records"
 decrease_user_value "$user" '$U_DNS_RECORDS' "$records"
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns $restart
     $BIN/v-restart-dns $restart
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Bind restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 5 - 4
bin/v-delete-dns-domains

@@ -11,6 +11,7 @@
 
 
 # Argument defenition
 # Argument defenition
 user=$1
 user=$1
+restart=$2
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
@@ -41,10 +42,10 @@ done
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
-$BIN/v-restart-dns
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
+# Restarting named
+if [ "$restart" != 'no' ]; then
+    $BIN/v-restart-dns
+    check_result $? "Bind restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 1 - 3
bin/v-delete-dns-domains-src

@@ -46,9 +46,7 @@ done
 # Restart named
 # Restart named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Bind restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-delete-dns-record

@@ -69,12 +69,10 @@ records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')"
 update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
 update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
 decrease_user_value "$user" '$U_DNS_RECORDS'
 decrease_user_value "$user" '$U_DNS_RECORDS'
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Bind restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 6
bin/v-delete-sys-ip

@@ -123,16 +123,12 @@ fi
 
 
 # Restarting web server
 # Restarting web server
 $BIN/v-restart-web
 $BIN/v-restart-web
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Web restart failed" >/dev/null
 
 
 # Restarting proxy server
 # Restarting proxy server
 if [ ! -z "$PROXY_SYSTEM" ]; then
 if [ ! -z "$PROXY_SYSTEM" ]; then
     $BIN/v-restart-proxy
     $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Proxy restart failed" >/dev/null
 fi
 fi
 
 
 # Restarting firewall
 # Restarting firewall

+ 3 - 7
bin/v-delete-web-domain

@@ -168,18 +168,14 @@ if [ "$SSL" = 'yes' ]; then
     decrease_user_value "$user" '$U_WEB_SSL'
     decrease_user_value "$user" '$U_WEB_SSL'
 fi
 fi
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
     if [ ! -z "$PROXY_SYSTEM" ]; then
     if [ ! -z "$PROXY_SYSTEM" ]; then
         $BIN/v-restart-proxy
         $BIN/v-restart-proxy
-        if [ $? -ne 0 ]; then
-            exit $E_RESTART
-        fi
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 6 - 8
bin/v-delete-web-domain-alias

@@ -73,7 +73,7 @@ if [ "$SSL" = 'yes' ]; then
 fi
 fi
 
 
 # Checking proxy
 # Checking proxy
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     del_web_config
     del_web_config
@@ -98,16 +98,14 @@ update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
 # Update counters
 # Update counters
 decrease_user_value "$user" '$U_WEB_ALIASES'
 decrease_user_value "$user" '$U_WEB_ALIASES'
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

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

@@ -52,12 +52,10 @@ rm -f $pool/$backend.conf
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart backend server
+# Restarting backend server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web-backend
     $BIN/v-restart-web-backend
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Backend restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 1 - 3
bin/v-delete-web-domain-proxy

@@ -87,9 +87,7 @@ fi
 # Restart proxy server
 # Restart proxy server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-proxy
     $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Proxy restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 6 - 8
bin/v-delete-web-domain-ssl

@@ -48,7 +48,7 @@ tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
 del_web_config
 del_web_config
 
 
 # Checking proxy
 # Checking proxy
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
     del_web_config
     del_web_config
@@ -89,16 +89,14 @@ fi
 # Decreasing domain value
 # Decreasing domain value
 decrease_user_value "$user" '$U_WEB_SSL'
 decrease_user_value "$user" '$U_WEB_SSL'
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 3 - 7
bin/v-delete-web-domains

@@ -42,18 +42,14 @@ done
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
     if [ ! -z "$PROXY_SYSTEM" ]; then
     if [ ! -z "$PROXY_SYSTEM" ]; then
         $BIN/v-restart-proxy
         $BIN/v-restart-proxy
-        if [ $? -ne 0 ]; then
-            exit $E_RESTART
-        fi
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 2 - 4
bin/v-insert-dns-domain

@@ -68,12 +68,10 @@ chmod 660 $USER_DATA/dns.conf
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns $restart
     $BIN/v-restart-dns $restart
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Bind restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-insert-dns-record

@@ -44,12 +44,10 @@ echo "$data" >> $USER_DATA/dns/$domain.conf
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns $restart
     $BIN/v-restart-dns $restart
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Bind restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-insert-dns-records

@@ -47,12 +47,10 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Bind restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-rebuild-cron-jobs

@@ -40,12 +40,10 @@ sync_cron_jobs
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart crond
+# Restarting crond
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-cron
     $BIN/v-restart-cron
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Cron restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-rebuild-dns-domain

@@ -81,12 +81,10 @@ update_user_value "$user" '$U_DNS_DOMAINS' "$user_domains"
 update_user_value "$user" '$U_DNS_RECORDS' "$user_records"
 update_user_value "$user" '$U_DNS_RECORDS' "$user_records"
 update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns"
 update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns"
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns "$restart"
     $BIN/v-restart-dns "$restart"
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Bind restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-rebuild-dns-domains

@@ -82,12 +82,10 @@ update_user_value "$user" '$U_DNS_DOMAINS' "$user_domains"
 update_user_value "$user" '$U_DNS_RECORDS' "$user_records"
 update_user_value "$user" '$U_DNS_RECORDS' "$user_records"
 update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns"
 update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns"
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Bind restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 4 - 8
bin/v-rebuild-web-domains

@@ -159,18 +159,14 @@ update_user_value "$user" '$U_WEB_DOMAINS' "$user_domains"
 update_user_value "$user" '$U_WEB_SSL' "$user_ssl"
 update_user_value "$user" '$U_WEB_SSL' "$user_ssl"
 update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases"
 update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases"
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
-    if [ ! -z "$PROXY_SYSTEM" ];then
+    if [ ! -z "$PROXY_SYSTEM" ]; then
         $BIN/v-restart-proxy
         $BIN/v-restart-proxy
-        if [ $? -ne 0 ]; then
-            exit $E_RESTART
-        fi
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 2 - 6
bin/v-start-service

@@ -29,14 +29,10 @@ check_args '1' "$#" 'SERVICE'
 
 
 if [ "$service" != 'iptables' ]; then
 if [ "$service" != 'iptables' ]; then
     service $service start >/dev/null 2>&1
     service $service start >/dev/null 2>&1
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "$service start failed" $E_RESTART
 else
 else
     $BIN/v-update-firewall
     $BIN/v-update-firewall
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "$service start failed" $E_RESTART
 fi
 fi
 
 
 
 

+ 2 - 6
bin/v-stop-service

@@ -29,14 +29,10 @@ check_args '1' "$#" 'SERVICE'
 
 
 if [ "$service" != 'iptables' ]; then
 if [ "$service" != 'iptables' ]; then
     service $service stop >/dev/null 2>&1
     service $service stop >/dev/null 2>&1
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "$service stop failed" $E_RESTART
 else
 else
     $BIN/v-stop-firewall
     $BIN/v-stop-firewall
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "$service stop failed" $E_RESTART
 fi
 fi
 
 
 
 

+ 2 - 4
bin/v-suspend-cron-job

@@ -46,12 +46,10 @@ sync_cron_jobs
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart crond
+# Restarting crond
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-cron
     $BIN/v-restart-cron
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Cron restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-suspend-cron-jobs

@@ -41,12 +41,10 @@ done
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart crond
+# Restarting crond
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-cron
     $BIN/v-restart-cron
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Cron restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 0 - 8
bin/v-suspend-dns-domain

@@ -46,14 +46,6 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
 sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/dns/$domain.conf
 sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/dns/$domain.conf
 increase_user_value "$user" '$SUSPENDED_DNS'
 increase_user_value "$user" '$SUSPENDED_DNS'
 
 
-# Restart named
-#if [ "$restart" != 'no' ]; then
-#    $BIN/v-restart-dns
-#    if [ $? -ne 0 ]; then
-#        exit $E_RESTART
-#    fi
-#fi
-
 # Logging
 # Logging
 log_event "$OK" "$EVENT"
 log_event "$OK" "$EVENT"
 
 

+ 0 - 8
bin/v-suspend-dns-domains

@@ -42,14 +42,6 @@ done
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart dns server
-#if [ "$restart" != 'no' ]; then
-#    $BIN/v-restart-dns
-#    if [ $? -ne 0 ]; then
-#        exit $E_RESTART
-#    fi
-#fi
-
 # Logging
 # Logging
 log_event "$OK" "$EVENT"
 log_event "$OK" "$EVENT"
 
 

+ 0 - 8
bin/v-suspend-dns-record

@@ -63,14 +63,6 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
-#if [ "$restart" != 'no' ]; then
-#    $BIN/v-restart-dns
-#    if [ $? -ne 0 ]; then
-#        exit $E_RESTART
-#    fi
-#fi
-
 # Logging
 # Logging
 log_event "$OK" "$EVENT"
 log_event "$OK" "$EVENT"
 
 

+ 4 - 10
bin/v-suspend-user

@@ -73,22 +73,16 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart web server
+# Restarting system services
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 
 
     $BIN/v-restart-cron
     $BIN/v-restart-cron
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Cron restart failed" >/dev/null
 fi
 fi
 
 
 # Changing suspend value
 # Changing suspend value

+ 14 - 16
bin/v-suspend-web-domain

@@ -63,41 +63,39 @@ if [ "$SSL" = 'yes' ]; then
 fi
 fi
 
 
 # Checking proxy
 # Checking proxy
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     del_web_config
     del_web_config
     add_web_config
     add_web_config
 
 
+    # Checking proxy SSL
+    if [ "$SSL" = 'yes' ]; then
+        tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
+        conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
+        del_web_config
+        add_web_config
+    fi
 fi
 fi
 
 
-# Checking proxy SSL
-if [ ! -z "$PROXY" ] && [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
-    conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
-    del_web_config
-    add_web_config
-fi
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Update config
+# Updating config
 update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
 update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
 increase_user_value "$user" '$SUSPENDED_WEB'
 increase_user_value "$user" '$SUSPENDED_WEB'
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 5 - 7
bin/v-suspend-web-domains

@@ -42,16 +42,14 @@ done
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 2 - 4
bin/v-unsuspend-cron-job

@@ -46,12 +46,10 @@ sync_cron_jobs
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart crond
+# Restarting crond
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-cron
     $BIN/v-restart-cron
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Cron restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 4
bin/v-unsuspend-cron-jobs

@@ -41,12 +41,10 @@ done
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart crond
+# Restarting crond
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-cron
     $BIN/v-restart-cron
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Cron restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 0 - 9
bin/v-unsuspend-dns-domain

@@ -47,15 +47,6 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'no'
 decrease_user_value "$user" '$SUSPENDED_DNS'
 decrease_user_value "$user" '$SUSPENDED_DNS'
 sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/dns/$domain.conf
 sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/dns/$domain.conf
 
 
-
-# Restart named
-#if [ "$restart" != 'no' ]; then
-#    $BIN/v-restart-dns
-#    if [ $? -ne 0 ]; then
-#        exit $E_RESTART
-#    fi
-#fi
-
 # Logging
 # Logging
 log_event "$OK" "$EVENT"
 log_event "$OK" "$EVENT"
 
 

+ 0 - 8
bin/v-unsuspend-dns-domains

@@ -42,14 +42,6 @@ done
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart dns server
-#if [ "$restart" != 'no' ]; then
-#    $BIN/v-restart-dns
-#    if [ $? -ne 0 ]; then
-#        exit $E_RESTART
-#    fi
-#fi
-
 # Logging
 # Logging
 log_event "$OK" "$EVENT"
 log_event "$OK" "$EVENT"
 
 

+ 0 - 8
bin/v-unsuspend-dns-record

@@ -62,14 +62,6 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
-#if [ "$restart" != 'no' ]; then
-#    $BIN/v-restart-dns
-#    if [ $? -ne 0 ]; then
-#        exit $E_RESTART
-#    fi
-#fi
-
 # Logging
 # Logging
 log_event "$OK" "$EVENT"
 log_event "$OK" "$EVENT"
 
 

+ 4 - 9
bin/v-unsuspend-user

@@ -76,21 +76,16 @@ fi
 update_user_value "$user" '$SUSPENDED' 'no'
 update_user_value "$user" '$SUSPENDED' 'no'
 decrease_user_value 'admin' '$SUSPENDED_USERS'
 decrease_user_value 'admin' '$SUSPENDED_USERS'
 
 
+# Restarting system services
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 
 
     $BIN/v-restart-cron
     $BIN/v-restart-cron
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Cron restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 15 - 17
bin/v-unsuspend-web-domain

@@ -52,7 +52,7 @@ upd_web_domain_values
 del_web_config
 del_web_config
 add_web_config
 add_web_config
 
 
-# Check SSL
+# Checking SSL
 if [ "$SSL" = 'yes' ]; then
 if [ "$SSL" = 'yes' ]; then
     tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
     tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
     conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
@@ -61,19 +61,19 @@ if [ "$SSL" = 'yes' ]; then
 fi
 fi
 
 
 # Checking proxy
 # Checking proxy
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     del_web_config
     del_web_config
     add_web_config
     add_web_config
-fi
 
 
-# Checking SSL proxy
-if [ ! -z "$PROXY" ] && [ "$SSL" = 'yes' ]; then
-    tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
-    conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
-    del_web_config
-    add_web_config
+    # Checking proxy SSL
+    if [ "$SSL" = 'yes' ]; then
+        tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
+        conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
+        del_web_config
+        add_web_config
+    fi
 fi
 fi
 
 
 
 
@@ -81,20 +81,18 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Update config
+# Updating config
 update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no'
 update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no'
 decrease_user_value "$user" '$SUSPENDED_WEB'
 decrease_user_value "$user" '$SUSPENDED_WEB'
 
 
-# Restart web erver
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 5 - 7
bin/v-unsuspend-web-domains

@@ -43,16 +43,14 @@ done
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 1 - 3
bin/v-update-sys-ip

@@ -87,9 +87,7 @@ if [ ! -z "$vst_ip_list" ] && [ "$vst_ip_num" -eq '1' ]; then
                 $BIN/v-rebuild-dns-domains $user no
                 $BIN/v-rebuild-dns-domains $user no
             done
             done
             $BIN/v-restart-dns
             $BIN/v-restart-dns
-            if [ $? -ne 0 ]; then
-                exit $E_RESTART
-            fi
+            check_result $? "dns restart failed" >/dev/null
         fi
         fi
 
 
         # No further comparation is needed
         # No further comparation is needed

+ 2 - 10
bin/v-update-sys-vesta

@@ -42,11 +42,7 @@ if [ -e "/etc/redhat-release" ]; then
 
 
     # Update vesta package
     # Update vesta package
     $yum update $package > /dev/null 2>&1
     $yum update $package > /dev/null 2>&1
-    if [ $? -ne 0 ]; then
-        echo "Error: $package update failed"
-        log_event "$E_UPDATE" "$EVENT"
-        exit $E_UPDATE
-    fi
+    check_result $? "$pacakge update failed" $E_UPDATE
 else
 else
     # Update repo
     # Update repo
     apt-get update -o Dir::Etc::sourcelist="sources.list.d/vesta.list" \
     apt-get update -o Dir::Etc::sourcelist="sources.list.d/vesta.list" \
@@ -54,11 +50,7 @@ else
 
 
     # Update vesta package
     # Update vesta package
     apt-get install $package -qq > /dev/null 2>&1
     apt-get install $package -qq > /dev/null 2>&1
-    if [ $? -ne 0 ]; then
-        echo "Error: $package update failed"
-        log_event "$E_UPDATE" "$EVENT"
-        exit $E_UPDATE
-    fi
+    check_result $? "$pacakge update failed" $E_UPDATE
 fi
 fi