]> git.pld-linux.org Git - packages/unbound.git/blob - unbound.init
38df892a24d0601a9d932d7ec46d3403957f0eb9
[packages/unbound.git] / unbound.init
1 #!/bin/sh
2 #
3 # unbound               This shell script takes care of starting and stopping
4 #               unbound (DNS server).
5 #
6 # chkconfig:    345 14 89
7 #
8 # description:  unbound (BIND) is a Domain Name Server (DNS) \
9 #               that is used to resolve host names to IP addresses.
10
11 # Source function library
12 . /etc/rc.d/init.d/functions
13
14 # Source networking configuration
15 . /etc/sysconfig/network
16
17 UNBOUND_OPT=""
18
19 # Try get config..
20 [ -f /etc/sysconfig/unbound ] && . /etc/sysconfig/unbound
21
22 # Check that networking is up.
23 if is_yes "${NETWORKING}"; then
24         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
25                 msg_network_down "Unbound"
26                 exit 1
27         fi
28 else
29         exit 0
30 fi
31
32 # Sanity check
33 [ -e /etc/unbound/unbound.conf ] || exit 0
34
35 start() {
36         # Check if the service is already running?
37         if [ ! -f /var/lock/subsys/unbound ]; then
38                 msg_starting "Unbound"
39                 daemon /usr/sbin/unbound \
40                         -c /etc/unbound/unbound.conf $UNBOUND_OPT </dev/null
41                 RETVAL=$?
42                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/unbound
43         else
44                 msg_already_running "Unbound"
45         fi
46 }
47
48 stop() {
49         if [ -f /var/lock/subsys/unbound ]; then
50                 msg_stopping "Unbound"
51                 killproc unbound
52                 rm -f /var/lock/subsys/unbound >/dev/null 2>&1
53         else
54                 msg_not_running "Unbound"
55         fi
56 }
57
58 RETVAL=0
59 # See how we were called.
60 case "$1" in
61   start)
62         start
63         ;;
64   stop)
65         stop
66         ;;
67   status)
68         status unbound
69         RETVAL=$?
70         if [ -f /etc/rndc.conf ]; then
71                 /usr/sbin/rndc status
72                 RET=$?
73                 if [ $RET -ne 0 ]; then
74                         RETVAL=$RET
75                 fi
76         fi
77         ;;
78   reload|force-reload)
79         if [ -f /var/lock/subsys/unbound ]; then
80                 if [ -f /etc/rndc.conf ]; then
81                         run_cmd "$(nls 'Reloading %s service' 'Unbound')" /usr/sbin/rndc reload
82                 else
83                         msg_reloading "Unbound"
84                         killproc unbound -HUP
85                         RETVAL=$?
86                 fi
87         else
88                 msg_not_running "Unbound"
89                 exit 7
90         fi
91
92         ;;
93   restart)
94         stop
95         start
96         ;;
97   *)
98         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
99         exit 3
100 esac
101
102 exit $RETVAL
This page took 0.040049 seconds and 2 git commands to generate.