diff --git a/bin/v-restart-cron b/bin/v-restart-cron index 86ef72cd1..872231112 100755 --- a/bin/v-restart-cron +++ b/bin/v-restart-cron @@ -34,6 +34,19 @@ if [ ! -z "$CRON_SYSTEM" ]; then if [ $? -ne 0 ]; then /etc/init.d/$CRON_SYSTEM restart >/dev/null 2>&1 if [ $? -ne 0 ]; then + if [ -e "$VESTA/web/inc/mail-wrapper.php" ]; then + send_mail="$VESTA/web/inc/mail-wrapper.php" + else + send_mail=$(which mail) + fi + 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 fi diff --git a/bin/v-restart-dns b/bin/v-restart-dns index 9fc0dbeb5..40e78cf30 100755 --- a/bin/v-restart-dns +++ b/bin/v-restart-dns @@ -34,6 +34,19 @@ if [ ! -z "$DNS_SYSTEM" ]; then if [ $? -ne 0 ]; then /etc/init.d/$DNS_SYSTEM restart >/dev/null 2>&1 if [ $? -ne 0 ]; then + if [ -e "$VESTA/web/inc/mail-wrapper.php" ]; then + send_mail="$VESTA/web/inc/mail-wrapper.php" + else + send_mail=$(which mail) + fi + email=$(grep CONTACT $VESTA/data/users/admin/user.conf) + email=$(echo "$email" | cut -f 2 -d "'") + tmpfile=$(mktemp) + subj="$(hostname): $DNS_SYSTEM restart failed" + /etc/init.d/$DNS_SYSTEM configtest >> $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 fi diff --git a/bin/v-restart-ftp b/bin/v-restart-ftp index a8e4d8a8b..da106347d 100755 --- a/bin/v-restart-ftp +++ b/bin/v-restart-ftp @@ -34,6 +34,19 @@ if [ ! -z "$FTP_SYSTEM" ]; then if [ $? -ne 0 ]; then /etc/init.d/$FTP_SYSTEM restart >/dev/null 2>&1 if [ $? -ne 0 ]; then + if [ -e "$VESTA/web/inc/mail-wrapper.php" ]; then + send_mail="$VESTA/web/inc/mail-wrapper.php" + else + send_mail=$(which mail) + fi + 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 diff --git a/bin/v-restart-mail b/bin/v-restart-mail index c3c537f97..4afcd4692 100755 --- a/bin/v-restart-mail +++ b/bin/v-restart-mail @@ -34,6 +34,19 @@ if [ ! -z "$MAIL_SYSTEM" ]; then if [ $? -ne 0 ]; then /etc/init.d/$MAIL_SYSTEM restart >/dev/null 2>&1 if [ $? -ne 0 ]; then + if [ -e "$VESTA/web/inc/mail-wrapper.php" ]; then + send_mail="$VESTA/web/inc/mail-wrapper.php" + else + send_mail=$(which mail) + fi + 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 diff --git a/bin/v-restart-proxy b/bin/v-restart-proxy index 36363268d..67e12cf7e 100755 --- a/bin/v-restart-proxy +++ b/bin/v-restart-proxy @@ -34,6 +34,19 @@ if [ ! -z "$PROXY_SYSTEM" ]; then if [ $? -ne 0 ]; then /etc/init.d/$PROXY_SYSTEM restart >/dev/null 2>&1 if [ $? -ne 0 ]; then + if [ -e "$VESTA/web/inc/mail-wrapper.php" ]; then + send_mail="$VESTA/web/inc/mail-wrapper.php" + else + send_mail=$(which mail) + fi + 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 fi diff --git a/bin/v-restart-service b/bin/v-restart-service index cf41b4931..dfffab6ba 100755 --- a/bin/v-restart-service +++ b/bin/v-restart-service @@ -30,6 +30,19 @@ check_args '1' "$#" 'SERVICE' if [ -x "/etc/init.d/$service" ]; then /etc/init.d/$service restart >/dev/null 2>&1 if [ $? -ne 0 ]; then + if [ -e "$VESTA/web/inc/mail-wrapper.php" ]; then + send_mail="$VESTA/web/inc/mail-wrapper.php" + else + send_mail=$(which mail) + fi + email=$(grep CONTACT $VESTA/data/users/admin/user.conf) + email=$(echo "$email" | cut -f 2 -d "'") + tmpfile=$(mktemp) + subj="$(hostname): $service restart failed" + /etc/init.d/$service configtest >> $tmpfile 2>&1 + /etc/init.d/$service restart >> $tmpfile 2>&1 + cat $tmpfile | $send_mail -s "$subj" $email + rm -f $tmpfile exit $E_RESTART fi fi diff --git a/bin/v-restart-web b/bin/v-restart-web index 337fbc2c0..28bb73e06 100755 --- a/bin/v-restart-web +++ b/bin/v-restart-web @@ -31,9 +31,22 @@ fi # Restart system if [ ! -z "$WEB_SYSTEM" ]; then /etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1 - if [ $? -ne 0 ]; then + if [ "$?" -ne 0 ]; then /etc/init.d/$WEB_SYSTEM restart >/dev/null 2>&1 if [ $? -ne 0 ]; then + if [ -e "$VESTA/web/inc/mail-wrapper.php" ]; then + send_mail="$VESTA/web/inc/mail-wrapper.php" + else + send_mail=$(which mail) + fi + 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 exit $E_RESTART fi fi