]> git.pld-linux.org Git - packages/pdns.git/blob - pdns.init
- initial revision
[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_no "${NETWORKING}"; then
17         msg_network_down "pdns"
18         exit 1
19 fi
20
21 BINARYPATH=/usr/sbin
22 SBINARYPATH=/usr/sbin
23 SOCKETPATH=/var/run
24
25 cd /var/run
26 suffix=`basename $0 | awk -F- '{print $2}'`
27 if [ $suffix ] 
28 then
29         EXTRAOPTS=--config-name=$suffix
30         PROGNAME=pdns-$suffix
31 else
32         PROGNAME=pdns
33 fi
34
35 pdns_server="/usr/sbin/pdns_server $EXTRAOPTS"
36
37 doPC() {
38     ret=$(/usr/sbin/pdns_control $EXTRAOPTS $1 $2 2> /dev/null)
39 }
40
41 if [ "$1" != "mrtg" -a "$1" != "cricket" ] 
42 then
43         echo -n "$PROGNAME: "
44 fi
45
46 doPC ping
47 NOTRUNNING=$?
48
49 case "$1" in
50         status)
51                 if test "$NOTRUNNING" = "0" 
52                 then 
53                         doPC status
54                         echo $ret
55                 else
56                         echo "not running"
57                 fi 
58         ;;      
59
60         stop)
61                 if test "$NOTRUNNING" = "0" 
62                 then 
63                         doPC quit
64                         echo $ret
65                 else
66                         echo "not running"
67                 fi 
68         ;;              
69
70         force-stop)
71                 killall -v -9 pdns_server
72         ;;
73
74         start)
75                 if test "$NOTRUNNING" = "0" 
76                 then 
77                         echo "already running"
78                 else
79                         $pdns_server --daemon --guardian=yes
80                         if test "$?" = "0"
81                         then
82                                 echo "started"  
83                         fi
84                 fi 
85         ;;              
86
87         force-reload | restart)
88                 echo -n stopping and waiting
89                 doPC quit
90                 sleep 3
91                 echo 
92                 $0 start
93         ;;
94
95         reload) 
96                 if test "$NOTRUNNING" = "0" 
97                 then 
98                         doPC cycle
99                         echo requested reload
100                 else
101                         echo not running yet
102                         $0 start
103                 fi 
104         ;;              
105                 
106         monitor)
107                 if test "$NOTRUNNING" = "0" 
108                 then 
109                         echo "already running"
110                 else
111                         $pdns_server --daemon=no --guardian=no --control-console --loglevel=9
112                 fi 
113         ;;              
114
115         dump)
116                 if test "$NOTRUNNING" = "0" 
117                 then 
118                         doPC list
119                         echo $ret
120                 else
121                         echo "not running"
122                 fi 
123         ;;              
124
125         show)
126                 if [ $# -lt 2 ]
127                 then
128                         echo Insufficient parameters
129                         exit
130                 fi 
131                 if test "$NOTRUNNING" = "0" 
132                 then 
133                         echo -n "$2="
134                         doPC show $2 ; echo $ret
135                 else
136                         echo "not running"
137                 fi 
138         ;;              
139
140         mrtg)
141                 if [ $# -lt 2 ]
142                 then
143                         echo Insufficient parameters
144                         exit
145                 fi 
146                 if test "$NOTRUNNING" = "0" 
147                 then 
148                         doPC show $2 ; echo $ret
149                         if [ "$3x" != "x" ]
150                         then
151                                 doPC show $3 ; echo $ret
152                         else
153                                 echo 0
154                         fi
155                         doPC uptime ; echo $ret
156                         echo PowerDNS daemon
157                 else
158                         echo "not running"
159                 fi 
160         
161         ;;              
162
163         cricket)
164                 if [ $# -lt 2 ]
165                 then
166                         echo Insufficient parameters
167                         exit
168                 fi 
169                 if test "$NOTRUNNING" = "0" 
170                 then 
171                         doPC show $2 ; echo $ret
172                 else
173                         echo "not running"
174                 fi 
175         
176         ;;              
177
178
179
180         *)
181         echo pdns [start\|stop\|force-reload\|restart\|status\|dump\|show\|mrtg\|cricket\|monitor]
182
183         ;;
184 esac
185
186
This page took 0.07504 seconds and 4 git commands to generate.