|
|
@@ -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
|
|
|
|