05f86a0
#!/bin/sh
05f86a0
#
05f86a0
# unbound	This shell script takes care of starting and stopping
05f86a0
#		unbound (DNS server).
05f86a0
#
05f86a0
# chkconfig:   - 14 86
05f86a0
# description:	unbound is a Domain Name Server (DNS) \
05f86a0
#		that is used to resolve host names to IP addresses.
05f86a0
05f86a0
### BEGIN INIT INFO
05f86a0
# Provides: unbound
05f86a0
# Required-Start: $network $local_fs
05f86a0
# Required-Stop: $network $local_fs
05f86a0
# Should-Start: $syslog
05f86a0
# Should-Stop: $syslog
05f86a0
# Short-Description: unbound recursive Domain Name Server.
05f86a0
# Description:  unbound is a Domain Name Server (DNS) 
05f86a0
#		that is used to resolve host names to IP addresses.
05f86a0
### END INIT INFO
05f86a0
05f86a0
# Source function library.
05f86a0
. /etc/rc.d/init.d/functions
05f86a0
05f86a0
exec="/usr/sbin/unbound"
12d3cd5
config="/etc/unbound/unbound.conf"
05f86a0
rootdir="/var/lib/unbound"
05f86a0
pidfile="/var/run/unbound/unbound.pid"
05f86a0
05f86a0
[ -e /etc/sysconfig/unbound ] && . /etc/sysconfig/unbound
05f86a0
05f86a0
lockfile=/var/lock/subsys/unbound
05f86a0
05f86a0
start() {
05f86a0
    [ -x $exec ] || exit 5
05f86a0
    [ -f $config ] || exit 6
ec151e1
12d3cd5
    if [ ! -f /etc/unbound/unbound_control.key ]
ec151e1
    then
ec151e1
	echo -n $"Generating unbound control key and certificate: "
12d3cd5
	/usr/sbin/unbound-control-setup -d /etc/unbound/ > /dev/null 2> /dev/null
Adam Tkac cd8c012
	[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled && \
Adam Tkac cd8c012
	    [ -x /sbin/restorecon ] && /sbin/restorecon /etc/unbound/*
ec151e1
	echo
ec151e1
    fi
ec151e1
05f86a0
    echo -n $"Starting unbound: "
05f86a0
05f86a0
    # if not running, start it up here
05f86a0
    daemon $exec
05f86a0
    retval=$?
05f86a0
    [ $retval -eq 0 ] && touch $lockfile
05f86a0
    echo
05f86a0
}
05f86a0
05f86a0
stop() {
05f86a0
    echo -n $"Stopping unbound: "
05f86a0
    # stop it here, often "killproc unbound"
05f86a0
    killproc -p $pidfile unbound
05f86a0
    retval=$?
05f86a0
    [ $retval -eq 0 ] && rm -f $lockfile
05f86a0
    echo
05f86a0
}
05f86a0
05f86a0
restart() {
05f86a0
    stop
05f86a0
    start
05f86a0
}
05f86a0
05f86a0
reload() {
05f86a0
    kill -HUP `cat $pidfile`
05f86a0
}
05f86a0
05f86a0
force_reload() {
05f86a0
    restart
05f86a0
}
05f86a0
05f86a0
rh_status() {
05f86a0
    # run checks to determine if the service is running or use generic status
05f86a0
    status -p $pidfile unbound
05f86a0
}
05f86a0
05f86a0
rh_status_q() {
05f86a0
    rh_status -p $pidfile >/dev/null 2>&1
05f86a0
}
05f86a0
05f86a0
case "$1" in
05f86a0
    start)
05f86a0
        start
05f86a0
        ;;
05f86a0
    stop)
05f86a0
        stop
05f86a0
        ;;
05f86a0
    restart)
05f86a0
        restart
05f86a0
        ;;
05f86a0
    reload)
05f86a0
        reload
05f86a0
        ;;
05f86a0
    force-reload)
05f86a0
        force_reload
05f86a0
        ;;
05f86a0
    status)
05f86a0
        rh_status
05f86a0
        ;;
05f86a0
    condrestart|try-restart)
05f86a0
        rh_status_q || exit 0
05f86a0
        restart
05f86a0
        ;;
05f86a0
    *)
05f86a0
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
05f86a0
        exit 2
05f86a0
esac
05f86a0
exit $?