]> git.pld-linux.org Git - packages/pdns.git/blob - pdns.init
- LSB conformance
[packages/pdns.git] / pdns.init
1 #!/bin/sh
2 # pdns          This is controller stript for PowerDNS name server.
3 #
4 # chkconfig:    345 80 75
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 ]; 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 ] 
32 then
33         EXTRAOPTS=--config-name=$suffix
34         PROGNAME=pdns-$suffix
35 else
36         PROGNAME=pdns
37 fi
38
39 pdns_server="/usr/sbin/pdns_server $EXTRAOPTS"
40
41 doPC() {
42         ret=$(/usr/sbin/pdns_control $EXTRAOPTS $1 $2 2> /dev/null)
43 }
44
45 doPC ping
46 NOTRUNNING=$?
47
48
49 case "$1" in
50   status)
51         status pdns_server
52         exit $?
53         ;;      
54   stop)
55         if test "$NOTRUNNING" = "0"; then 
56                 msg_stopping "PowerDNS"
57                 doPC quit 2>&1 >/dev/null
58                 [ $? -eq 0 ] && ok || fail
59                 rm /var/lock/subsys/pdns
60         else
61                 msg_not_running "PowerDNS"
62         fi 
63         ;;              
64   force-stop)
65         run_cmd "Killing PowerDNS without grace" killall -v -9 pdns_server
66         ;;
67   start)
68         if test "$NOTRUNNING" = "0"; then 
69                 msg_already_running "PowerDNS"
70         else
71                 msg_starting "PowerDNS (Powered DNS server)"
72                 daemon $pdns_server --daemon --guardian=yes
73                 RETVAL=$?
74                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pdns
75         fi
76         ;;
77   restart)
78         $0 stop
79         run_cmd "PowerDNS (3 sec. timeout)" sleep 3
80         $0 start
81         exit $?
82         ;;
83   reload|force-reload) 
84         if test "$NOTRUNNING" = "0"; then 
85                 show "Reloading PowerDNS"
86                 doPC cycle 2>&1 >/dev/null
87                 [ $? -eq 0 ] && ok || fail
88         else
89                 msg_not_running "PowerDNS"
90                 $0 start
91         fi
92         ;;              
93   monitor)
94         if test "$NOTRUNNING" = "0"; then 
95                 msg_already_running "PowerDNS"
96         else
97                 show "PowerDNS in foreground (testing mode)"
98                 $pdns_server --daemon=no --guardian=no --control-console --loglevel=9
99         fi 
100         ;;              
101   dump)
102         if test "$NOTRUNNING" = "0"; then 
103                 doPC list
104                 echo $ret
105         else
106                 msg_not_running "PowerDNS"
107         fi 
108         ;;              
109   show)
110         if [ $# -lt 2 ]; then
111                 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
112                 exit 1
113         fi 
114         if test "$NOTRUNNING" = "0"; then 
115                 echo -n "$2="
116                 doPC show $2 ; echo $ret
117         else
118                 msg_not_running "PowerDNS"
119         fi 
120         ;;              
121   mrtg)
122         if [ $# -lt 2 ]; then
123                 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
124                 exit 1
125         fi 
126         if test "$NOTRUNNING" = "0"; then 
127                 doPC show $2 ; echo $ret
128                 if [ "$3x" != "x" ]; then
129                         doPC show $3 ; echo $ret
130                 else
131                         echo 0
132                 fi
133                 doPC uptime ; echo $ret
134                 echo PowerDNS daemon
135         else
136                 msg_not_running "PowerDNS"
137                 exit 1
138         fi 
139         ;;              
140   cricket)
141         if [ $# -lt 2 ]; then
142                 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
143                 exit 1
144         fi 
145         if test "$NOTRUNNING" = "0"; then 
146                 doPC show $2 ; echo $ret
147         else
148                 msg_not_running "PowerDNS"
149                 exit 1
150         fi 
151         ;;              
152   *)
153         msg_usage "$0 {start|stop|restart|reload|force-reload|status|dump|show|mrtg|cricket|monitor} [...]"
154         exit 3
155 esac
156
157 exit $RETVAL
This page took 0.15862 seconds and 4 git commands to generate.