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