2008-10-31 22:29:15 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# unbound This shell script takes care of starting and stopping
|
|
|
|
# unbound (DNS server).
|
|
|
|
#
|
|
|
|
# chkconfig: - 14 86
|
|
|
|
# description: unbound is a Domain Name Server (DNS) \
|
|
|
|
# that is used to resolve host names to IP addresses.
|
|
|
|
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: unbound
|
|
|
|
# Required-Start: $network $local_fs
|
|
|
|
# Required-Stop: $network $local_fs
|
2009-06-21 02:52:35 +00:00
|
|
|
# Default-Start:
|
|
|
|
# Default-Stop: 0 1 2 3 4 5 6
|
2008-10-31 22:29:15 +00:00
|
|
|
# Should-Start: $syslog
|
|
|
|
# Should-Stop: $syslog
|
|
|
|
# Short-Description: unbound recursive Domain Name Server.
|
|
|
|
# Description: unbound is a Domain Name Server (DNS)
|
|
|
|
# that is used to resolve host names to IP addresses.
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
exec="/usr/sbin/unbound"
|
2008-11-19 23:11:51 +00:00
|
|
|
config="/etc/unbound/unbound.conf"
|
2008-10-31 22:29:15 +00:00
|
|
|
rootdir="/var/lib/unbound"
|
|
|
|
pidfile="/var/run/unbound/unbound.pid"
|
2009-01-26 23:02:22 +00:00
|
|
|
piddir=`dirname $pidfile`
|
2008-10-31 22:29:15 +00:00
|
|
|
|
|
|
|
[ -e /etc/sysconfig/unbound ] && . /etc/sysconfig/unbound
|
2009-03-09 20:36:02 +00:00
|
|
|
[ -e /etc/sysconfig/dnssec ] && . /etc/sysconfig/dnssec
|
2008-10-31 22:29:15 +00:00
|
|
|
|
|
|
|
lockfile=/var/lock/subsys/unbound
|
|
|
|
|
2009-03-09 20:36:02 +00:00
|
|
|
[ -x /usr/sbin/dnssec-configure ] && [ -r "$config" ] &&
|
|
|
|
[ /etc/sysconfig/dnssec -nt "$config" ] && \
|
|
|
|
/usr/sbin/dnssec-configure -u --norestart --dnssec="$DNSSEC" --dlv="$DLV"
|
|
|
|
|
2008-10-31 22:29:15 +00:00
|
|
|
start() {
|
|
|
|
[ -x $exec ] || exit 5
|
|
|
|
[ -f $config ] || exit 6
|
2009-01-26 23:02:22 +00:00
|
|
|
# /var/run could (and should) be tmpfs
|
|
|
|
[ -d $piddir ] || mkdir $piddir
|
2008-11-15 06:41:55 +00:00
|
|
|
|
2008-11-19 23:11:51 +00:00
|
|
|
if [ ! -f /etc/unbound/unbound_control.key ]
|
2008-11-15 06:41:55 +00:00
|
|
|
then
|
|
|
|
echo -n $"Generating unbound control key and certificate: "
|
2008-11-19 23:11:51 +00:00
|
|
|
/usr/sbin/unbound-control-setup -d /etc/unbound/ > /dev/null 2> /dev/null
|
2009-05-20 16:15:09 +00:00
|
|
|
chgrp unbound /etc/unbound/unbound_*key /etc/unbound/unbound_*pem
|
2008-11-28 09:46:49 +00:00
|
|
|
[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled && \
|
|
|
|
[ -x /sbin/restorecon ] && /sbin/restorecon /etc/unbound/*
|
2008-11-15 06:41:55 +00:00
|
|
|
echo
|
2009-05-20 16:15:09 +00:00
|
|
|
else
|
|
|
|
# old init script created these as root instead of unbound.
|
|
|
|
if [ -G /etc/unbound/unbound_control.key ]
|
|
|
|
then
|
|
|
|
chgrp unbound /etc/unbound/unbound_*key /etc/unbound/unbound_*pem
|
|
|
|
[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled && \
|
|
|
|
[ -x /sbin/restorecon ] && /sbin/restorecon /etc/unbound/*
|
|
|
|
echo
|
|
|
|
fi
|
2008-11-15 06:41:55 +00:00
|
|
|
fi
|
|
|
|
|
2008-10-31 22:29:15 +00:00
|
|
|
echo -n $"Starting unbound: "
|
|
|
|
|
|
|
|
# if not running, start it up here
|
2009-01-26 23:02:22 +00:00
|
|
|
daemon --pidfile=$pidfile $exec
|
2008-10-31 22:29:15 +00:00
|
|
|
retval=$?
|
|
|
|
[ $retval -eq 0 ] && touch $lockfile
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
echo -n $"Stopping unbound: "
|
|
|
|
# stop it here, often "killproc unbound"
|
|
|
|
killproc -p $pidfile unbound
|
|
|
|
retval=$?
|
|
|
|
[ $retval -eq 0 ] && rm -f $lockfile
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
|
|
|
kill -HUP `cat $pidfile`
|
|
|
|
}
|
|
|
|
|
|
|
|
force_reload() {
|
|
|
|
restart
|
|
|
|
}
|
|
|
|
|
|
|
|
rh_status() {
|
|
|
|
# run checks to determine if the service is running or use generic status
|
|
|
|
status -p $pidfile unbound
|
|
|
|
}
|
|
|
|
|
|
|
|
rh_status_q() {
|
|
|
|
rh_status -p $pidfile >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
restart
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
reload
|
|
|
|
;;
|
|
|
|
force-reload)
|
|
|
|
force_reload
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
rh_status
|
|
|
|
;;
|
|
|
|
condrestart|try-restart)
|
|
|
|
rh_status_q || exit 0
|
|
|
|
restart
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
|
|
|
exit 2
|
|
|
|
esac
|
|
|
|
exit $?
|