]> git.pld-linux.org Git - packages/pdns.git/blob - pdns.init
- fixes compatibility with later boost and later stdlib
[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 RETVAL=0
48 case "$1" in
49   status)
50         status pdns_server
51         exit $?
52         ;;
53   stop)
54         if test "$NOTRUNNING" = "0"; then
55                 msg_stopping "PowerDNS"
56                 doPC quit 2>&1 >/dev/null
57                 [ $? -eq 0 ] && ok || fail
58                 rm /var/lock/subsys/pdns
59         else
60                 msg_not_running "PowerDNS"
61         fi
62         ;;
63   force-stop)
64         run_cmd "Killing PowerDNS without grace" killall -v -9 pdns_server
65         ;;
66   start)
67         if test "$NOTRUNNING" = "0"; then
68                 msg_already_running "PowerDNS"
69         else
70                 msg_starting "PowerDNS (Powered DNS server)"
71                 daemon $pdns_server --daemon --guardian=yes
72                 RETVAL=$?
73                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pdns
74         fi
75         ;;
76   restart)
77         $0 stop
78         run_cmd "PowerDNS (3 sec. timeout)" sleep 3
79         $0 start
80         exit $?
81         ;;
82   reload|force-reload)
83         if test "$NOTRUNNING" = "0"; then
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         else
93                 msg_not_running "PowerDNS" >&2
94                 exit 7
95         fi
96         ;;
97   monitor)
98         if test "$NOTRUNNING" = "0"; then
99                 msg_already_running "PowerDNS"
100         else
101                 show "PowerDNS in foreground (testing mode)"
102                 $pdns_server --daemon=no --guardian=no --control-console --loglevel=9
103         fi
104         ;;
105   dump)
106         if test "$NOTRUNNING" = "0"; then
107                 doPC list
108                 echo $ret
109         else
110                 msg_not_running "PowerDNS"
111         fi
112         ;;
113   show)
114         if [ $# -lt 2 ]; then
115                 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
116                 exit 2
117         fi
118         if test "$NOTRUNNING" = "0"; then
119                 echo -n "$2="
120                 doPC show $2 ; echo $ret
121         else
122                 msg_not_running "PowerDNS"
123         fi
124         ;;
125   mrtg)
126         if [ $# -lt 2 ]; then
127                 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
128                 exit 2
129         fi
130         if test "$NOTRUNNING" = "0"; then
131                 doPC show $2 ; echo $ret
132                 if [ "$3x" != "x" ]; then
133                         doPC show $3 ; echo $ret
134                 else
135                         echo 0
136                 fi
137                 doPC uptime ; echo $ret
138                 echo PowerDNS daemon
139         else
140                 msg_not_running "PowerDNS" >&2
141                 exit 7
142         fi
143         ;;
144   cricket)
145         if [ $# -lt 2 ]; then
146                 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
147                 exit 2
148         fi
149         if test "$NOTRUNNING" = "0"; then
150                 doPC show $2 ; echo $ret
151         else
152                 msg_not_running "PowerDNS" >&2
153                 exit 7
154         fi
155         ;;
156   *)
157         msg_usage "$0 {start|stop|restart|reload|force-reload|status|dump|show|mrtg|cricket|monitor} [...]"
158         exit 3
159 esac
160
161 exit $RETVAL
This page took 0.070248 seconds and 3 git commands to generate.