]> git.pld-linux.org Git - packages/pdns.git/blob - pdns.init
boost rebuild
[packages/pdns.git] / pdns.init
1 #!/bin/sh
2 # pdns          This is controller stript for PowerDNS name server.
3 #
4 # chkconfig:    345 85 15
5 #
6 # description:  pdns is is a Domain Name Server (DNS) \
7 #               that is used to resolve host names to IP addresses.
8
9 # Source function library
10 . /etc/rc.d/init.d/functions
11
12 # Source networking configuration
13 . /etc/sysconfig/network
14
15 # Check that networking is up.
16 if is_yes "${NETWORKING}"; then
17         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
18                 msg_network_down "PowerDNS"
19                 exit 1
20         fi
21 else
22         exit 0
23 fi
24
25 BINARYPATH=/usr/sbin
26 SBINARYPATH=/usr/sbin
27 SOCKETPATH=/var/run
28
29 cd /var/run
30 suffix=`basename $0 | awk -F- '{print $2}'`
31 if [ $suffix ]; then
32         EXTRAOPTS=--config-name=$suffix
33         PROGNAME=pdns-$suffix
34 else
35         PROGNAME=pdns
36 fi
37
38 pdns_server="/usr/sbin/pdns_server $EXTRAOPTS"
39
40 doPC() {
41         ret=$(/usr/bin/pdns_control $EXTRAOPTS $1 $2 2> /dev/null)
42 }
43
44 doPC ping
45 NOTRUNNING=$?
46
47 start() {
48         if test "$NOTRUNNING" = "0"; then
49                 msg_already_running "PowerDNS"
50                 return
51         fi
52
53         msg_starting "PowerDNS (Powered DNS server)"
54         daemon $pdns_server --daemon --guardian=yes
55         RETVAL=$?
56         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pdns
57 }
58
59 stop() {
60         if test "$NOTRUNNING" != "0"; then
61                 msg_not_running "PowerDNS"
62                 return
63         fi
64
65         msg_stopping "PowerDNS"
66         doPC quit 2>&1 >/dev/null
67         [ $? -eq 0 ] && ok || fail
68         rm /var/lock/subsys/pdns
69 }
70
71 restart() {
72         stop
73         run_cmd "PowerDNS (3 sec. timeout)" sleep 3
74         start
75 }
76
77 reload() {
78         if test "$NOTRUNNING" != "0"; then
79                 msg_not_running "PowerDNS" >&2
80                 RETVAL=7
81                 return
82         fi
83
84         show "Reloading PowerDNS"
85         doPC cycle 2>&1 >/dev/null
86         if [ $? -eq 0 ]; then
87                 ok
88         else
89                 fail
90                 RETVAL=1
91         fi
92 }
93
94 monitor() {
95         if test "$NOTRUNNING" = "0"; then
96                 msg_already_running "PowerDNS"
97                 return
98         fi
99
100         show "PowerDNS in foreground (testing mode)"
101         $pdns_server --daemon=no --guardian=no --control-console --loglevel=9
102 }
103
104 dump() {
105         if test "$NOTRUNNING" != "0"; then
106                 msg_not_running "PowerDNS"
107                 return
108         fi
109
110         doPC list
111         echo $ret
112 }
113
114 show() {
115         if [ $# -lt 2 ]; then
116                 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
117                 RETVAL=2
118                 return
119         fi
120
121         if test "$NOTRUNNING" = "0"; then
122                 echo -n "$2="
123                 doPC show $2 ; echo $ret
124         else
125                 msg_not_running "PowerDNS"
126         fi
127 }
128
129 mrtg() {
130         if [ $# -lt 2 ]; then
131                 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
132                 RETVAL=2
133         fi
134
135         if test "$NOTRUNNING" = "0"; then
136                 doPC show $2 ; echo $ret
137                 if [ "$3x" != "x" ]; then
138                         doPC show $3 ; echo $ret
139                 else
140                         echo 0
141                 fi
142                 doPC uptime ; echo $ret
143                 echo PowerDNS daemon
144         else
145                 msg_not_running "PowerDNS" >&2
146                 exit 7
147         fi
148 }
149
150 cricket() {
151         if [ $# -lt 2 ]; then
152                 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
153                 RETVAL=2
154         fi
155
156         if test "$NOTRUNNING" = "0"; then
157                 doPC show $2 ; echo $ret
158         else
159                 msg_not_running "PowerDNS" >&2
160                 exit 7
161         fi
162 }
163
164 RETVAL=0
165 case "$1" in
166   stop)
167         stop
168         ;;
169   force-stop)
170         run_cmd "Killing PowerDNS without grace" killall -v -9 pdns_server
171         ;;
172   start)
173         start
174         ;;
175   restart)
176         restart
177         ;;
178   reload|force-reload)
179         reload
180         ;;
181   monitor)
182         monitor
183         ;;
184   dump)
185         dump
186         ;;
187   show)
188         show "$@"
189         ;;
190   mrtg)
191         mrtg "$@"
192         ;;
193   cricket)
194         cricket "$@"
195         ;;
196   status)
197         status pdns_server
198         ;;
199   *)
200         msg_usage "$0 {start|stop|restart|reload|force-reload|status|dump|show|mrtg|cricket|monitor} [...]"
201         exit 3
202 esac
203
204 exit $RETVAL
This page took 0.04133 seconds and 3 git commands to generate.