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