| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #!/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
- PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
- 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"
- /usr/sbin/named-checkconf $dns_conf >> $tmpfile 2>&1
- service $DNS_SYSTEM restart >> $tmpfile 2>&1
- cat $tmpfile |$SENDMAIL -s "$subj" $email
- rm -f $tmpfile
- }
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Exit
- if [ "$1" = "no" ]; then
- exit
- fi
- # 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
- if [ -z "$DNS_SYSTEM" ] || [ "$DNS_SYSTEM" = 'remote' ] ; then
- exit
- fi
- # Restart system
- service $DNS_SYSTEM reload >/dev/null 2>&1
- if [ $? -ne 0 ]; then
- service $DNS_SYSTEM restart >/dev/null 2>&1
- if [ $? -ne 0 ]; then
- send_email_report
- check_result $E_RESTART "$DNS_SYSTEM restart failed"
- fi
- fi
- # Update restart queue
- if [ -e "$VESTA/data/queue/restart.pipe" ]; then
- sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe
- fi
- #----------------------------------------------------------#
- # Vesta #
- #----------------------------------------------------------#
- exit
|