Package: unbound
Version: 1.4.16-1~bpo60+1
Severity: normal

The initscript for unbound doesn't support the 'status' command. This isn't LSB 
compatible and is hard to monitor. This patch adds this to the script.

-- System Information:
Debian Release: 6.0.4
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages unbound depends on:
ii  adduser                 3.112+nmu2       add and remove users and groups
ii  libc6                   2.11.3-3         Embedded GNU C Library: Shared lib
ii  libevent-1.4-2          1.4.13-stable-1  An asynchronous event notification
ii  libldns1                1.6.11-1~bpo60+1 ldns library for DNS programming
ii  libpython2.6            2.6.6-8+b1       Shared Python runtime library (ver
ii  libssl0.9.8             0.9.8o-4squeeze7 SSL shared libraries
ii  openssl                 0.9.8o-4squeeze7 Secure Socket Layer (SSL) binary a
ii  unbound-anchor          1.4.16-1~bpo60+1 utility to securely fetch the root

unbound recommends no packages.

unbound suggests no packages.

-- Configuration Files:
/etc/unbound/unbound.conf changed [not included]

-- no debconf information
--- unbound.orig        2012-03-30 10:57:44.687748433 +0200
+++ unbound     2012-03-30 11:18:30.507743942 +0200
@@ -88,6 +88,31 @@
     fi
 }
 
+do_status() {
+    echo -n "${NAME} is "
+    out="`/usr/sbin/unbound-control status 2>/dev/null`"
+    if [ $? -eq 0 ]; then # Running
+        echo "$out" | grep "running" | grep -q "`cat $PIDFILE`"
+        if [ $? -eq 0 ]; then
+            echo "running"
+            exit 0
+        else # Data in PIDFILE is wrong
+            echo "running, but PIDFILE doesn't match"
+            exit 4
+        fi
+    else # not running
+        echo -n "not running"
+        if [ -s $PIDFILE ]; then
+            echo " and a pid-file exists ($PIDFILE)"
+            exit 1
+        fi
+        echo ""
+        exit 3
+    fi
+    echo "unknown"
+    exit 4
+}
+
 case "$1" in
     start)
         if $UNBOUND_ENABLE; then
@@ -144,9 +169,13 @@
         fi
         ;;
 
+     status)
+        do_status
+        ;;
+
     *)
         N=/etc/init.d/$NAME
-        echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
+        echo "Usage: $N {start|stop|restart|status|reload|force-reload}" >&2
         exit 1
         ;;
 esac

Reply via email to