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