]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/pdns.init.in
dnsdist: Refactoring to merge the UDP and TCP paths
[thirdparty/pdns.git] / pdns / pdns.init.in
1 #!/bin/sh
2 # chkconfig: - 80 75
3 # description: PDNS is a versatile high performance authoritative nameserver
4
5 ### BEGIN INIT INFO
6 # Provides: pdns
7 # Required-Start: $remote_fs $network $syslog
8 # Required-Stop: $remote_fs $network $syslog
9 # Should-Start:
10 # Should-Stop:
11 # Default-Start: 2 3 4 5
12 # Default-Stop: 0 1 6
13 # Short-Description: PowerDNS authoritative server
14 # Description: PowerDNS authoritative server
15 ### END INIT INFO
16
17 set -e
18
19 exec_prefix=@exec_prefix@
20 BINARYPATH=@bindir@
21 SBINARYPATH=@sbindir@
22 SOCKETPATH=@socketdir@
23 DAEMON_ARGS=""
24
25 [ -f "$SBINARYPATH/pdns_server" ] || exit 0
26
27 [ -r /etc/default/pdns ] && . /etc/default/pdns
28
29 [ "$START" = "no" ] && exit 0
30
31 # Make sure that /var/run exists
32 mkdir -p $SOCKETPATH
33 cd $SOCKETPATH
34 suffix=$(basename $0 | cut -d- -f2- -s)
35 if [ -n "$suffix" ]
36 then
37 EXTRAOPTS=--config-name=$suffix
38 PROGNAME=pdns-$suffix
39 else
40 PROGNAME=pdns
41 fi
42
43 pdns_server="$SBINARYPATH/pdns_server $DAEMON_ARGS $EXTRAOPTS"
44
45 doPC()
46 {
47 ret=$($BINARYPATH/pdns_control $EXTRAOPTS $1 $2 2> /dev/null)
48 }
49
50 NOTRUNNING=0
51 doPC ping || NOTRUNNING=$?
52
53 case "$1" in
54 status)
55 if test "$NOTRUNNING" = "0"
56 then
57 doPC status
58 echo $ret
59 else
60 echo "not running"
61 exit 3
62 fi
63 ;;
64
65 stop)
66 echo -n "Stopping PowerDNS authoritative nameserver: "
67 if test "$NOTRUNNING" = "0"
68 then
69 doPC quit
70 echo $ret
71 else
72 echo "not running"
73 fi
74 ;;
75
76
77 force-stop)
78 echo -n "Stopping PowerDNS authoritative nameserver: "
79 killall -v -9 pdns_server
80 echo "killed"
81 ;;
82
83 start)
84 echo -n "Starting PowerDNS authoritative nameserver: "
85 if test "$NOTRUNNING" = "0"
86 then
87 echo "already running"
88 else
89 if $pdns_server --daemon --guardian=yes
90 then
91 echo "started"
92 else
93 echo "starting failed"
94 exit 1
95 fi
96 fi
97 ;;
98
99 force-reload | restart)
100 echo -n "Restarting PowerDNS authoritative nameserver: "
101 if test "$NOTRUNNING" = "1"
102 then
103 echo "not running, starting"
104 else
105
106 echo -n stopping and waiting..
107 doPC quit
108 sleep 3
109 echo done
110 fi
111 $0 start
112 ;;
113
114 reload)
115 echo -n "Reloading PowerDNS authoritative nameserver: "
116 if test "$NOTRUNNING" = "0"
117 then
118 doPC cycle
119 echo requested reload
120 else
121 echo not running yet
122 $0 start
123 fi
124 ;;
125
126 monitor)
127 if test "$NOTRUNNING" = "0"
128 then
129 echo "already running"
130 else
131 $pdns_server --daemon=no --guardian=no --control-console --loglevel=9
132 fi
133 ;;
134
135 dump)
136 if test "$NOTRUNNING" = "0"
137 then
138 doPC list
139 echo $ret
140 else
141 echo "not running"
142 fi
143 ;;
144
145 show)
146 if [ $# -lt 2 ]
147 then
148 echo Insufficient parameters
149 exit
150 fi
151 if test "$NOTRUNNING" = "0"
152 then
153 echo -n "$2="
154 doPC show $2 ; echo $ret
155 else
156 echo "not running"
157 fi
158 ;;
159
160 mrtg)
161 if [ $# -lt 2 ]
162 then
163 echo Insufficient parameters
164 exit
165 fi
166 if test "$NOTRUNNING" = "0"
167 then
168 doPC show $2 ; echo $ret
169 if [ "$3x" != "x" ]
170 then
171 doPC show $3 ; echo $ret
172 else
173 echo 0
174 fi
175 doPC uptime ; echo $ret
176 echo PowerDNS daemon
177 else
178 echo "not running"
179 fi
180
181 ;;
182
183 cricket)
184 if [ $# -lt 2 ]
185 then
186 echo Insufficient parameters
187 exit
188 fi
189 if test "$NOTRUNNING" = "0"
190 then
191 doPC show $2 ; echo $ret
192 else
193 echo "not running"
194 fi
195
196 ;;
197
198
199
200 *)
201 echo pdns [start\|stop\|force-reload\|reload\|restart\|status\|dump\|show\|mrtg\|cricket\|monitor]
202
203 ;;
204 esac
205
206