Serghey Rodin 12 лет назад
Родитель
Сommit
e7c94357a4
6 измененных файлов с 140 добавлено и 95 удалено
  1. 22 14
      bin/v-restart-cron
  2. 27 22
      bin/v-restart-dns
  3. 20 17
      bin/v-restart-ftp
  4. 21 17
      bin/v-restart-mail
  5. 21 15
      bin/v-restart-proxy
  6. 29 10
      bin/v-restart-web

+ 22 - 14
bin/v-restart-cron

@@ -13,6 +13,18 @@
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
 
+send_email_report() {
+    send_mail="$VESTA/web/inc/mail-wrapper.php"
+    email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
+    email=$(echo "$email" | cut -f 2 -d "'")
+    tmpfile=$(mktemp)
+    subj="$(hostname): $CRON_SYSTEM restart failed"
+    /etc/init.d/$CRON_SYSTEM configtest >> $tmpfile 2>&1
+    /etc/init.d/$CRON_SYSTEM restart >> $tmpfile 2>&1
+    cat $tmpfile | $send_mail -s "$subj" $email
+    rm -f $tmpfile
+}
+
 
 #----------------------------------------------------------#
 #                       Action                             #
@@ -28,23 +40,19 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
     exit
 fi
 
+if [ -z "$CRON_SYSTEM" ]; then
+    exit
+fi
+
 # Restart system
-if [ ! -z "$CRON_SYSTEM" ]; then
+if [ -e "/var/run/crond.pid" ]; then
     /etc/init.d/$CRON_SYSTEM reload >/dev/null 2>&1
+    reload cron >/dev/null 2>&1
+else
+    /etc/init.d/$CRON_SYSTEM restart >/dev/null 2>&1
     if [ $? -ne 0 ]; then
-        /etc/init.d/$CRON_SYSTEM restart >/dev/null 2>&1
-        if [ $? -ne 0 ]; then
-            send_mail="$VESTA/web/inc/mail-wrapper.php"
-            email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
-            email=$(echo "$email" | cut -f 2 -d "'")
-            tmpfile=$(mktemp)
-            subj="$(hostname): $CRON_SYSTEM restart failed"
-            /etc/init.d/$CRON_SYSTEM configtest >> $tmpfile 2>&1
-            /etc/init.d/$CRON_SYSTEM restart >> $tmpfile 2>&1
-            cat $tmpfile | $send_mail -s "$subj" $email
-            rm -f $tmpfile
-            exit $E_RESTART
-        fi
+        send_email_report
+        exit $E_RESTART
     fi
 fi
 

+ 27 - 22
bin/v-restart-dns

@@ -13,6 +13,24 @@
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
 
+send_email_report() {
+    if [ -e '/etc/named.conf' ]; then
+        dns_conf='/etc/named.conf'
+    else
+        dns_conf='/etc/bind/named.conf'
+    fi
+
+    send_mail="$VESTA/web/inc/mail-wrapper.php"
+    email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
+    email=$(echo "$email" | cut -f 2 -d "'")
+    tmpfile=$(mktemp)
+    subj="$(hostname): $DNS_SYSTEM restart failed"
+    named-checkconf $dns_conf >> $tmpfile 2>&1
+    /etc/init.d/$DNS_SYSTEM restart >> $tmpfile 2>&1
+    cat $tmpfile | $send_mail -s "$subj" $email
+    rm -f $tmpfile
+}
+
 
 #----------------------------------------------------------#
 #                       Action                             #
@@ -28,30 +46,17 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
     exit
 fi
 
+if [ -z "$DNS_SYSTEM" ]; then
+    exit
+fi
+
 # Restart system
-if [ ! -z "$DNS_SYSTEM" ]; then
-    /etc/init.d/$DNS_SYSTEM reload >/dev/null 2>&1
+/etc/init.d/$DNS_SYSTEM reload >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+    /etc/init.d/$DNS_SYSTEM restart >/dev/null 2>&1
     if [ $? -ne 0 ]; then
-        /etc/init.d/$DNS_SYSTEM restart >/dev/null 2>&1
-        if [ $? -ne 0 ]; then
-            send_mail="$VESTA/web/inc/mail-wrapper.php"
-            email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
-            email=$(echo "$email" | cut -f 2 -d "'")
-            tmpfile=$(mktemp)
-            subj="$(hostname): $DNS_SYSTEM restart failed"
-
-            # Get dns config path
-            if [ -e '/etc/named.conf' ]; then
-                dns_conf='/etc/named.conf'
-            else
-                dns_conf='/etc/bind/named.conf'
-            fi
-            named-checkconf $dns_conf >> $tmpfile 2>&1
-            /etc/init.d/$DNS_SYSTEM restart >> $tmpfile 2>&1
-            cat $tmpfile | $send_mail -s "$subj" $email
-            rm -f $tmpfile
-            exit $E_RESTART
-        fi
+        send_email_report
+        exit $E_RESTART
     fi
 fi
 

+ 20 - 17
bin/v-restart-ftp

@@ -13,6 +13,18 @@
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
 
+send_email_report() {
+    send_mail="$VESTA/web/inc/mail-wrapper.php"
+    email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
+    email=$(echo "$email" | cut -f 2 -d "'")
+    tmpfile=$(mktemp)
+    subj="$(hostname): $FTP_SYSTEM restart failed"
+    /etc/init.d/$FTP_SYSTEM configtest >> $tmpfile 2>&1
+    /etc/init.d/$FTP_SYSTEM restart >> $tmpfile 2>&1
+    cat $tmpfile | $send_mail -s "$subj" $email
+    rm -f $tmpfile
+}
+
 
 #----------------------------------------------------------#
 #                       Action                             #
@@ -28,24 +40,15 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
     exit
 fi
 
+if [ -z "$FTP_SYSTEM" ]; then
+    exit
+fi
+
 # Restart system
-if [ ! -z "$FTP_SYSTEM" ]; then
-    /etc/init.d/$FTP_SYSTEM reload >/dev/null 2>&1
-    if [ $? -ne 0 ]; then
-        /etc/init.d/$FTP_SYSTEM restart >/dev/null 2>&1
-        if [ $? -ne 0 ]; then
-            send_mail="$VESTA/web/inc/mail-wrapper.php"
-            email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
-            email=$(echo "$email" | cut -f 2 -d "'")
-            tmpfile=$(mktemp)
-            subj="$(hostname): $FTP_SYSTEM restart failed"
-            /etc/init.d/$FTP_SYSTEM configtest >> $tmpfile 2>&1
-            /etc/init.d/$FTP_SYSTEM restart >> $tmpfile 2>&1
-            cat $tmpfile | $send_mail -s "$subj" $email
-            rm -f $tmpfile
-            exit $E_RESTART
-        fi
-    fi
+/etc/init.d/$FTP_SYSTEM restart >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+    send_email_report
+    exit $E_RESTART
 fi
 
 # Update restart queue

+ 21 - 17
bin/v-restart-mail

@@ -13,6 +13,18 @@
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
 
+send_email_report() {
+    send_mail="$VESTA/web/inc/mail-wrapper.php"
+    email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
+    email=$(echo "$email" | cut -f 2 -d "'")
+    tmpfile=$(mktemp)
+    subj="$(hostname): $MAIL_SYSTEM restart failed"
+    /etc/init.d/$MAIL_SYSTEM configtest >> $tmpfile 2>&1
+    /etc/init.d/$MAIL_SYSTEM restart >> $tmpfile 2>&1
+    cat $tmpfile | $send_mail -s "$subj" $email
+    rm -f $tmpfile
+}
+
 
 #----------------------------------------------------------#
 #                       Action                             #
@@ -28,24 +40,16 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
     exit
 fi
 
+
+if [ -z "$MAIL_SYSTEM" ]; then
+    exit
+fi
+
 # Restart system
-if [ ! -z "$MAIL_SYSTEM" ]; then
-    /etc/init.d/$MAIL_SYSTEM reload >/dev/null 2>&1
-    if [ $? -ne 0 ]; then
-        /etc/init.d/$MAIL_SYSTEM restart >/dev/null 2>&1
-        if [ $? -ne 0 ]; then
-            send_mail="$VESTA/web/inc/mail-wrapper.php"
-            email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
-            email=$(echo "$email" | cut -f 2 -d "'")
-            tmpfile=$(mktemp)
-            subj="$(hostname): $MAIL_SYSTEM restart failed"
-            /etc/init.d/$MAIL_SYSTEM configtest >> $tmpfile 2>&1
-            /etc/init.d/$MAIL_SYSTEM restart >> $tmpfile 2>&1
-            cat $tmpfile | $send_mail -s "$subj" $email
-            rm -f $tmpfile
-            exit $E_RESTART
-        fi
-    fi
+/etc/init.d/$MAIL_SYSTEM restart >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+    send_email_report
+    exit $E_RESTART
 fi
 
 # Update restart queue

+ 21 - 15
bin/v-restart-proxy

@@ -13,6 +13,18 @@
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
 
+send_email_report() {
+    send_mail="$VESTA/web/inc/mail-wrapper.php"
+    email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
+    email=$(echo "$email" | cut -f 2 -d "'")
+    tmpfile=$(mktemp)
+    subj="$(hostname): $PROXY_SYSTEM restart failed"
+    /etc/init.d/$PROXY_SYSTEM configtest >> $tmpfile 2>&1
+    /etc/init.d/$PROXY_SYSTEM restart >> $tmpfile 2>&1
+    cat $tmpfile | $send_mail -s "$subj" $email
+    rm -f $tmpfile
+}
+
 
 #----------------------------------------------------------#
 #                       Action                             #
@@ -28,23 +40,17 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
     exit
 fi
 
+if [ -z "$PROXY_SYSTEM" ]; then
+    exit
+fi
+
 # Restart system
-if [ ! -z "$PROXY_SYSTEM" ]; then
-    /etc/init.d/$PROXY_SYSTEM reload >/dev/null 2>&1
+/etc/init.d/$PROXY_SYSTEM reload >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+    /etc/init.d/$PROXY_SYSTEM restart >/dev/null 2>&1
     if [ $? -ne 0 ]; then
-        /etc/init.d/$PROXY_SYSTEM restart >/dev/null 2>&1
-        if [ $? -ne 0 ]; then
-            send_mail="$VESTA/web/inc/mail-wrapper.php"
-            email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
-            email=$(echo "$email" | cut -f 2 -d "'")
-            tmpfile=$(mktemp)
-            subj="$(hostname): $PROXY_SYSTEM restart failed"
-            /etc/init.d/$PROXY_SYSTEM configtest >> $tmpfile 2>&1
-            /etc/init.d/$PROXY_SYSTEM restart >> $tmpfile 2>&1
-            cat $tmpfile | $send_mail -s "$subj" $email
-            rm -f $tmpfile
-            exit $E_RESTART
-        fi
+        send_email_report
+        exit $E_RESTART
     fi
 fi
 

+ 29 - 10
bin/v-restart-web

@@ -13,6 +13,18 @@
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
 
+send_email_report() {
+    send_mail="$VESTA/web/inc/mail-wrapper.php"
+    email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
+    email=$(echo "$email" | cut -f 2 -d "'")
+    tmpfile=$(mktemp)
+    subj="$(hostname): $WEB_SYSTEM restart failed"
+    /etc/init.d/$WEB_SYSTEM configtest >> $tmpfile 2>&1
+    /etc/init.d/$WEB_SYSTEM restart >> $tmpfile 2>&1
+    cat $tmpfile | $send_mail -s "$subj" $email
+    rm -f $tmpfile
+}
+
 
 #----------------------------------------------------------#
 #                       Action                             #
@@ -28,21 +40,28 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
     exit
 fi
 
+
+if [ -z "$WEB_SYSTEM" ]; then
+    exit
+fi
+
 # Restart system
-if [ ! -z "$WEB_SYSTEM" ]; then
+if [ "$WEB_SYSTEM" == 'apache2' ]; then
+    if [ -e "/var/run/apache2.pid" ]; then
+        /etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1
+    else
+        /etc/init.d/$WEB_SYSTEM restart >/dev/null 2>&1
+        if [ $? -ne 0 ]; then
+            send_email_report
+            exit $E_RESTART
+        fi
+    fi
+else
     /etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1
     if [ "$?" -ne 0 ]; then
         /etc/init.d/$WEB_SYSTEM restart >/dev/null 2>&1
         if [ $? -ne 0 ]; then
-            send_mail="$VESTA/web/inc/mail-wrapper.php"
-            email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
-            email=$(echo "$email" | cut -f 2 -d "'")
-            tmpfile=$(mktemp)
-            subj="$(hostname): $WEB_SYSTEM restart failed"
-            /etc/init.d/$WEB_SYSTEM configtest >> $tmpfile 2>&1
-            /etc/init.d/$WEB_SYSTEM restart >> $tmpfile 2>&1
-            cat $tmpfile | $send_mail -s "$subj" $email
-            rm -f $tmpfile
+            send_email_report
             exit $E_RESTART
         fi
     fi