[Python-apps-commits] r2715 - in packages/sabnzbdplus/trunk/debian (sabnzbdplus.init)

jcfp-guest at users.alioth.debian.org jcfp-guest at users.alioth.debian.org
Thu Apr 9 12:11:31 UTC 2009


    Date: Thursday, April 9, 2009 @ 12:11:30
  Author: jcfp-guest
Revision: 2715

Updated init script to provide a pid file

Modified:
  packages/sabnzbdplus/trunk/debian/sabnzbdplus.init

Modified: packages/sabnzbdplus/trunk/debian/sabnzbdplus.init
===================================================================
--- packages/sabnzbdplus/trunk/debian/sabnzbdplus.init	2009-04-08 22:07:20 UTC (rev 2714)
+++ packages/sabnzbdplus/trunk/debian/sabnzbdplus.init	2009-04-09 12:11:30 UTC (rev 2715)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2008 by JCF Ploemen <linux at jp.pp.ru>
+# Copyright (C) 2008-2009 by JCF Ploemen <linux at jp.pp.ru>
 # released under GPL, version 2 or later
 
 ### BEGIN INIT INFO
@@ -20,7 +20,8 @@
 DESC="SABnzbd+ binary newsgrabber"
 SETTINGS=/etc/default/sabnzbdplus
 OPTIONS="--daemon"
-PYTHONEXEC="$(readlink -f $(sed -n -e "1s/^#\!\([a-z0-9\.\/]\+\).*/\1/p" $DAEMON))"
+PYTHONEXEC="$(readlink -f $(sed -n '1s/^#\!\([a-z0-9\.\/]\+\).*/\1/p' $DAEMON))"
+PIDFILE=/var/run/sabnzbdplus.pid
 
 . /lib/lsb/init-functions
 
@@ -59,6 +60,9 @@
 			log_daemon_msg "Starting $DESC"
 			start-stop-daemon --quiet --chuid $USER --start --exec $DAEMON -- $OPTIONS
 			check_retval
+			# create a pidfile; we don't use it but some monitoring app likes to have one
+			[ -w $(dirname $PIDFILE) ] && \
+				pgrep -f -x -n -u $USER "$(sed -n '1s/^#\!//p' $DAEMON) $DAEMON $OPTIONS" > $PIDFILE
 		else
 			log_success_msg "$DESC: already running"
 		fi
@@ -72,6 +76,7 @@
 		else
 			log_success_msg "$DESC: not running"
 		fi
+		[ -f $PIDFILE ] && rm -f $PIDFILE
 	;;
 	force-reload|restart)
 		$0 stop




More information about the Python-apps-commits mailing list