]>
Commit | Line | Data |
---|---|---|
89c4ed63 A |
1 | #!/bin/sh |
2 | # | |
3 | # unbound This shell script takes care of starting and stopping | |
4 | # unbound (DNS server). | |
5 | # | |
6 | # chkconfig: - 14 86 | |
7 | # description: unbound is a Domain Name Server (DNS) \ | |
8 | # that is used to resolve host names to IP addresses. | |
9 | ||
10 | ### BEGIN INIT INFO | |
11 | # Provides: unbound | |
12 | # Required-Start: $network $local_fs | |
13 | # Required-Stop: $network $local_fs | |
14 | # Should-Start: $syslog | |
15 | # Should-Stop: $syslog | |
16 | # Short-Description: unbound recursive Domain Name Server. | |
17 | # Description: unbound is a Domain Name Server (DNS) | |
18 | # that is used to resolve host names to IP addresses. | |
19 | ### END INIT INFO | |
20 | ||
21 | # Source function library. | |
22 | . /etc/rc.d/init.d/functions | |
23 | ||
24 | exec="/usr/sbin/unbound" | |
25 | config="/var/lib/unbound/unbound.conf" | |
26 | rootdir="/var/lib/unbound" | |
27 | pidfile="/var/run/unbound/unbound.pid" | |
28 | ||
29 | [ -e /etc/sysconfig/unbound ] && . /etc/sysconfig/unbound | |
30 | ||
31 | lockfile=/var/lock/subsys/unbound | |
32 | ||
33 | start() { | |
34 | [ -x $exec ] || exit 5 | |
35 | [ -f $config ] || exit 6 | |
36 | echo -n $"Starting unbound: " | |
37 | ||
38 | if [ ! -e ${rootdir}/etc/resolv.conf ] || /usr/bin/cmp -s /etc/resolv.conf ${rootdir}/etc/resolv.conf; then | |
39 | cp -fp /etc/resolv.conf ${rootdir}/etc/resolv.conf | |
40 | fi; | |
41 | if [ ! -e ${rootdir}/etc/localtime ] || /usr/bin/cmp -s /etc/localtime ${rootdir}/etc/localtime; then | |
42 | cp -fp /etc/localtime ${rootdir}/etc/localtime | |
43 | fi; | |
44 | mount --bind -n /dev/log ${rootdir}/dev/log >/dev/null 2>&1; | |
45 | mount --bind -n /dev/random ${rootdir}/dev/random >/dev/null 2>&1; | |
46 | mount --bind -n /var/run/unbound ${rootdir}/var/run/unbound >/dev/null 2>&1; | |
47 | ||
48 | # if not running, start it up here | |
49 | daemon $exec | |
50 | retval=$? | |
51 | [ $retval -eq 0 ] && touch $lockfile | |
52 | echo | |
53 | } | |
54 | ||
55 | stop() { | |
56 | echo -n $"Stopping unbound: " | |
57 | # stop it here, often "killproc unbound" | |
58 | killproc -p $pidfile unbound | |
59 | retval=$? | |
60 | [ $retval -eq 0 ] && rm -f $lockfile | |
61 | for mountfile in /dev/log /dev/random /etc/localtime /etc/resolv.conf /var/run/unbound | |
62 | do | |
63 | if egrep -q '^/[^[:space:]]+[[:space:]]+'${rootdir}''${mountfile}'' /proc/mounts; then | |
64 | umount ${rootdir}$mountfile >/dev/null 2>&1 | |
65 | fi; | |
66 | done | |
67 | echo | |
68 | } | |
69 | ||
70 | restart() { | |
71 | stop | |
72 | start | |
73 | } | |
74 | ||
75 | reload() { | |
76 | kill -HUP `cat $pidfile` | |
77 | } | |
78 | ||
79 | force_reload() { | |
80 | restart | |
81 | } | |
82 | ||
83 | rh_status() { | |
84 | # run checks to determine if the service is running or use generic status | |
85 | status -p $pidfile unbound | |
86 | } | |
87 | ||
88 | rh_status_q() { | |
89 | rh_status -p $pidfile >/dev/null 2>&1 | |
90 | } | |
91 | ||
92 | case "$1" in | |
93 | start) | |
94 | start | |
95 | ;; | |
96 | stop) | |
97 | stop | |
98 | ;; | |
99 | restart) | |
100 | restart | |
101 | ;; | |
102 | reload) | |
103 | reload | |
104 | ;; | |
105 | force-reload) | |
106 | force_reload | |
107 | ;; | |
108 | status) | |
109 | rh_status | |
110 | ;; | |
111 | condrestart|try-restart) | |
112 | rh_status_q || exit 0 | |
113 | restart | |
114 | ;; | |
115 | *) | |
116 | echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" | |
117 | exit 2 | |
118 | esac | |
119 | exit $? |