]> git.pld-linux.org Git - packages/pdns.git/blame - pdns.init
- allow some actions when network is down
[packages/pdns.git] / pdns.init
CommitLineData
d5cc2b05 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.
51acdf4e 16if is_yes "${NETWORKING}"; then
eb1cb6ec 17 if [ ! -f /var/lock/subsys/network -a != stop -a != status ]; then
51acdf4e 18 msg_network_down "PowerDNS"
19 exit 1
20 fi
21else
22 exit 0
d5cc2b05 23fi
24
25BINARYPATH=/usr/sbin
26SBINARYPATH=/usr/sbin
27SOCKETPATH=/var/run
28
29cd /var/run
30suffix=`basename $0 | awk -F- '{print $2}'`
31if [ $suffix ]
32then
33 EXTRAOPTS=--config-name=$suffix
34 PROGNAME=pdns-$suffix
35else
36 PROGNAME=pdns
37fi
38
39pdns_server="/usr/sbin/pdns_server $EXTRAOPTS"
40
41doPC() {
51acdf4e 42 ret=$(/usr/sbin/pdns_control $EXTRAOPTS $1 $2 2> /dev/null)
d5cc2b05 43}
44
d5cc2b05 45doPC ping
46NOTRUNNING=$?
47
767d5c50 48RETVAL=0
d5cc2b05 49case "$1" in
51acdf4e 50 status)
f0d7fa7a 51 status pdns_server
52 exit $?
d5cc2b05 53 ;;
51acdf4e 54 stop)
55 if test "$NOTRUNNING" = "0"; then
56 msg_stopping "PowerDNS"
57 doPC quit 2>&1 >/dev/null
f0d7fa7a 58 [ $? -eq 0 ] && ok || fail
51acdf4e 59 rm /var/lock/subsys/pdns
60 else
61 msg_not_running "PowerDNS"
51acdf4e 62 fi
d5cc2b05 63 ;;
51acdf4e 64 force-stop)
65 run_cmd "Killing PowerDNS without grace" killall -v -9 pdns_server
d5cc2b05 66 ;;
51acdf4e 67 start)
68 if test "$NOTRUNNING" = "0"; then
69 msg_already_running "PowerDNS"
51acdf4e 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 ;;
f0d7fa7a 77 restart)
51acdf4e 78 $0 stop
79 run_cmd "PowerDNS (3 sec. timeout)" sleep 3
80 $0 start
f0d7fa7a 81 exit $?
d5cc2b05 82 ;;
f0d7fa7a 83 reload|force-reload)
51acdf4e 84 if test "$NOTRUNNING" = "0"; then
85 show "Reloading PowerDNS"
86 doPC cycle 2>&1 >/dev/null
f362320e 87 if [ $? -eq 0 ]; then
88 ok
89 else
90 fail
91 RETVAL=1
92 fi
51acdf4e 93 else
f362320e 94 msg_not_running "PowerDNS" >&2
95 exit 7
f0d7fa7a 96 fi
d5cc2b05 97 ;;
51acdf4e 98 monitor)
99 if test "$NOTRUNNING" = "0"; then
100 msg_already_running "PowerDNS"
101 else
102 show "PowerDNS in foreground (testing mode)"
103 $pdns_server --daemon=no --guardian=no --control-console --loglevel=9
104 fi
d5cc2b05 105 ;;
51acdf4e 106 dump)
107 if test "$NOTRUNNING" = "0"; then
108 doPC list
109 echo $ret
110 else
111 msg_not_running "PowerDNS"
112 fi
d5cc2b05 113 ;;
51acdf4e 114 show)
115 if [ $# -lt 2 ]; then
116 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
f362320e 117 exit 2
51acdf4e 118 fi
119 if test "$NOTRUNNING" = "0"; then
120 echo -n "$2="
121 doPC show $2 ; echo $ret
122 else
123 msg_not_running "PowerDNS"
124 fi
d5cc2b05 125 ;;
51acdf4e 126 mrtg)
127 if [ $# -lt 2 ]; then
128 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
f362320e 129 exit 2
51acdf4e 130 fi
131 if test "$NOTRUNNING" = "0"; then
132 doPC show $2 ; echo $ret
133 if [ "$3x" != "x" ]; then
134 doPC show $3 ; echo $ret
d5cc2b05 135 else
51acdf4e 136 echo 0
137 fi
138 doPC uptime ; echo $ret
139 echo PowerDNS daemon
140 else
f362320e 141 msg_not_running "PowerDNS" >&2
142 exit 7
51acdf4e 143 fi
d5cc2b05 144 ;;
51acdf4e 145 cricket)
146 if [ $# -lt 2 ]; then
147 msg_usage "$0 {show|mrtg|cricket} <variable_name_from_pdns_dump>"
f362320e 148 exit 2
51acdf4e 149 fi
150 if test "$NOTRUNNING" = "0"; then
151 doPC show $2 ; echo $ret
152 else
f362320e 153 msg_not_running "PowerDNS" >&2
154 exit 7
51acdf4e 155 fi
d5cc2b05 156 ;;
51acdf4e 157 *)
f0d7fa7a 158 msg_usage "$0 {start|stop|restart|reload|force-reload|status|dump|show|mrtg|cricket|monitor} [...]"
159 exit 3
d5cc2b05 160esac
161
51acdf4e 162exit $RETVAL
This page took 0.093492 seconds and 4 git commands to generate.