1
0
mirror of https://github.com/serghey-rodin/vesta.git synced 2025-03-12 04:36:25 -07:00
vesta/bin/v-restart-dns

78 lines
2.0 KiB
Plaintext
Raw Normal View History

2013-01-19 23:07:26 +02:00
#!/bin/bash
# info: restart dns service
# options: NONE
#
# The function tells BIND service to reload dns zone files.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
2016-08-09 17:36:36 +03:00
PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
2013-01-19 23:07:26 +02:00
2013-10-09 14:11:07 +03:00
send_email_report() {
if [ -e '/etc/named.conf' ]; then
dns_conf='/etc/named.conf'
else
dns_conf='/etc/bind/named.conf'
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"
2015-08-20 18:02:20 +03:00
/usr/sbin/named-checkconf $dns_conf >> $tmpfile 2>&1
2014-12-17 02:12:55 +02:00
service $DNS_SYSTEM restart >> $tmpfile 2>&1
cat $tmpfile |$SENDMAIL -s "$subj" $email
2013-10-09 14:11:07 +03:00
rm -f $tmpfile
}
2013-01-19 23:07:26 +02:00
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Exit
if [ "$1" = "no" ]; then
exit
fi
2013-06-01 14:25:44 +03:00
# Schedule restart
if [ "$1" = 'scheduled' ]; then
echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe
exit
fi
if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe
exit
fi
2014-03-23 16:14:21 +02:00
if [ -z "$DNS_SYSTEM" ] || [ "$DNS_SYSTEM" = 'remote' ] ; then
2013-10-09 14:11:07 +03:00
exit
fi
2013-06-01 14:25:44 +03:00
# Restart system
2014-12-17 02:12:55 +02:00
service $DNS_SYSTEM reload >/dev/null 2>&1
2013-10-09 14:11:07 +03:00
if [ $? -ne 0 ]; then
2014-12-17 02:12:55 +02:00
service $DNS_SYSTEM restart >/dev/null 2>&1
2013-05-31 11:08:25 +03:00
if [ $? -ne 0 ]; then
2013-10-09 14:11:07 +03:00
send_email_report
check_result $E_RESTART "$DNS_SYSTEM restart failed"
2013-01-19 23:07:26 +02:00
fi
fi
2013-06-01 14:25:44 +03:00
# Update restart queue
if [ -e "$VESTA/data/queue/restart.pipe" ]; then
sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe
fi
2013-01-19 23:07:26 +02:00
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit