Package: icecast2
Version: 2.3.2-9+deb7u2
Severity: normal
Tags: patch

It would be great to provide a way to query the status of the service.
This is useful for systems such as salt [1] to query the status of a
service.
[1] http://www.saltstack.com/community/

Other services (e.g. sshd) provide a status command for this purpose.

I'll provide a patch to add support for this feature. The patch is
tested on my system after these things:

 * install libxml2-utils (for xmllint)
 * create a folder /var/run/icecast2
 * set the owner to icecast2:icecast
 * set the pidfile in /etc/icecast2/icecast.xml to
   /var/run/icecast2/icecast.pid
 * restart the icecast server
 * Happiness!

Thank you very much,
Sven Herzberg

-- System Information:
Debian Release: 7.4
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 2.6.32-26-pve (SMP w/1 CPU core)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
diff --git a/debian/icecast2.init b/debian/icecast2.init
index f244804..d508caf 100644
--- a/debian/icecast2.init
+++ b/debian/icecast2.init
@@ -33,6 +33,7 @@ CONFIGDEFAULTFILE="/etc/default/icecast2"
 USERID=icecast2
 GROUPID=icecast
 ENABLE="false"
+PIDFILE="`xmllint --xpath '/icecast/paths/pidfile/text()' "$CONFIGFILE" 2>/dev/null`"
 
 # Reads config file (will override defaults above)
 [ -r "$CONFIGDEFAULTFILE" ] && . $CONFIGDEFAULTFILE
@@ -42,6 +43,8 @@ if [ "$ENABLE" != "true" ]; then
 	exit 0
 fi
 
+. /lib/lsb/init-functions
+
 set -e
 
 case "$1" in
@@ -69,6 +72,13 @@ case "$1" in
 		--exec $DAEMON -- -b -c $CONFIGFILE
 	echo "$NAME."
 	;;
+  status)
+	if test -z "$PIDFILE"; then
+		log_failure_msg "$NAME does not specify a pid file in $CONFIGFILE"
+		exit 1
+	fi
+	status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
+	;;
   *)
 	echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
 	exit 1

Reply via email to