Logoj0ke.net Open Build Service > Projects > home:opeter:powerdns33_centos5 > powerdns > pdns-init.patch
Sign Up | Log In

File pdns-init.patch of Package powerdns

x
 
1
diff -ru pdns-3.2/pdns/pdns.in pdns-3.2.fresh/pdns/pdns.in
2
--- pdns/pdns.in.orig   2013-05-22 08:23:55.921220023 +0200
3
+++ pdns/pdns.in    2013-05-22 08:23:36.721292790 +0200
4
@@ -2,20 +2,33 @@
5
 # chkconfig: - 80 75
6
 # description: PDNS is a versatile high performance authoritative nameserver
7
 
8
-prefix=/usr
9
-exec_prefix=/usr
10
-BINARYPATH=/usr/bin
11
-SBINARYPATH=/usr/sbin
12
-SOCKETPATH=/var/run
13
-
14
+### BEGIN INIT INFO
15
+# Provides:          pdns
16
+# Required-Start:    $remote_fs $network $syslog
17
+# Required-Stop:     $remote_fs $network $syslog
18
+# Should-Start:      $all
19
+# Should-Stop:       
20
+# Default-Start:     2 3 4 5
21
+# Default-Stop:      0 1 6
22
+# Short-Description: Start/stop PowerDNS authoritative server
23
+# Description:       Start/stop PowerDNS authoritative server
24
+### END INIT INFO
25
+
26
+set -e
27
+
28
+prefix=@prefix@
29
+exec_prefix=@exec_prefix@
30
+BINARYPATH=@bindir@
31
+SBINARYPATH=@sbindir@
32
+SOCKETPATH=@socketdir@
33
 
34
 [ -f "$SBINARYPATH/pdns_server" ] || exit 0
35
 
36
-cd $SOCKETPATH
37
-suffix=`basename $0 | awk -F- '{print $2}'`
38
-
39
+[ -r /etc/default/pdns ] && . /etc/default/pdns
40
 
41
-if [ $suffix ] 
42
+cd $SOCKETPATH
43
+suffix=$(basename $0 | cut -d- -f2- -s)
44
+if [ -n "$suffix" ] 
45
 then
46
    EXTRAOPTS=--config-name=$suffix
47
    PROGNAME=pdns-$suffix
48
@@ -30,9 +43,8 @@
49
    ret=$($BINARYPATH/pdns_control $EXTRAOPTS $1 $2 2> /dev/null)
50
 }
51
 
52
-
53
-doPC ping
54
-NOTRUNNING=$?
55
+NOTRUNNING=0
56
+doPC ping || NOTRUNNING=$?
57
 
58
 case "$1" in
59
    status)
60
@@ -42,6 +54,7 @@
61
            echo $ret
62
        else
63
            echo "not running"
64
+           exit 3
65
        fi 
66
    ;;  
67
 
68
@@ -50,7 +63,6 @@
69
        if test "$NOTRUNNING" = "0" 
70
        then 
71
            doPC quit
72
-           rm -f /var/lock/subsys/pdns
73
            echo $ret
74
        else
75
            echo "not running"
76
@@ -61,7 +73,6 @@
77
    force-stop)
78
        echo -n "Stopping PowerDNS authoritative nameserver: "
79
        killall -v -9 pdns_server
80
-       rm -f /var/lock/subsys/pdns
81
        echo "killed"
82
    ;;
83
 
84
@@ -71,21 +82,28 @@
85
        then 
86
            echo "already running"
87
        else
88
-           $pdns_server --daemon --guardian=yes
89
-           if test "$?" = "0"
90
+           if $pdns_server --daemon --guardian=yes
91
            then
92
-               touch /var/lock/subsys/pdns
93
                echo "started"  
94
+                   else
95
+               echo "starting failed"
96
+                       exit 1
97
            fi
98
        fi 
99
    ;;      
100
 
101
    force-reload | restart)
102
        echo -n "Restarting PowerDNS authoritative nameserver: "
103
-       echo -n stopping and waiting.. 
104
-       doPC quit
105
-       sleep 3
106
-       echo done
107
+       if test "$NOTRUNNING" = "1" 
108
+       then 
109
+           echo "not running, starting"
110
+       else
111
+           
112
+           echo -n stopping and waiting.. 
113
+           doPC quit
114
+           sleep 3
115
+           echo done
116
+       fi
117
        $0 start
118
    ;;
119
 
120
@@ -176,7 +194,7 @@
121
 
122
 
123
    *)
124
-   echo pdns [start\|stop\|force-reload\|restart\|status\|dump\|show\|mrtg\|cricket\|monitor]
125
+   echo pdns [start\|stop\|force-reload\|reload\|restart\|status\|dump\|show\|mrtg\|cricket\|monitor]
126
 
127
    ;;
128
 esac
129