--- etc.rc.d.init.d.mythbackend	2005-02-01 08:55:10.000000000 -0500
+++ etc.rc.d.init.d.mythbackend	2005-03-29 15:18:24.723334275 -0500
@@ -31,12 +31,14 @@
 # User who should start the mythbackend processes
 MBE_USER="root"
 # Directory holding the mythbackend binary
-MBE_LOCATION="/usr/local/bin/"
+MBE_LOCATION="/usr/local/bin"
 # Name of mythbackend binary
 MBE_PROG="mythbackend"
 # Full path to mythbackend log file
 MBE_LOGFILE="/var/tmp/mythbackend.log"
 
+LOCKFILE="/var/lock/subsys/${MBE_PROG}"
+
 # Source function library.
 . /etc/init.d/functions
 
@@ -45,7 +47,7 @@
   . /etc/sysconfig/mythbackend
 fi
 
-test -x ${MBE_LOCATION}${MBE_PROG} || exit 0
+test -x ${MBE_LOCATION}/${MBE_PROG} || exit 0
 
 RETVAL=0
 
@@ -54,13 +56,21 @@
 #
 
 start() {
+	if [ -n "`/sbin/pidof $MBE_PROG`" ]; then
+		echo "${MBE_PROG}: already running"
+		return 1
+	elif [ -f ${LOCKFILE} ]; then
+		echo "Removing stale mythbackend lock file"
+		rm ${LOCKFILE}
+	fi
+
 	# Check if mythbackend is already running
-	if [ ! -f /var/lock/subsys/${MBE_PROG} ]; then
+	if [ ! -f ${LOCKFILE} ]; then
 	    echo -n "Starting ${MBE_PROG}: "
 	    # /usr/local/bin/mythbackend -d -l /some/log/file
-	    daemon --user ${MBE_USER} ${MBE_LOCATION}${MBE_PROG} -d -l ${MBE_LOGFILE}
+	    daemon --user ${MBE_USER} ${MBE_LOCATION}/${MBE_PROG} -d -l ${MBE_LOGFILE} ${MBE_EXTRA_OPTIONS}
 	    RETVAL=$?
-	    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/${MBE_PROG}
+	    [ $RETVAL -eq 0 ] && touch ${LOCKFILE}
 	    echo
 	fi
 	return $RETVAL
@@ -68,9 +78,9 @@
 
 stop() {
 	echo -n "Stopping ${MBE_PROG}: "
-	killproc ${MBE_LOCATION}${MBE_PROG}
+	killproc ${MBE_LOCATION}/${MBE_PROG}
 	RETVAL=$?
-	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${MBE_PROG}
+	[ $RETVAL -eq 0 ] && rm -f ${LOCKFILE}
 	echo
         return $RETVAL
 }
@@ -86,7 +96,7 @@
 }	
 
 status_at() {
- 	status ${MBE_LOCATION}${MBE_PROG}
+ 	status ${MBE_LOCATION}$/{MBE_PROG}
 }
 
 case "$1" in
@@ -100,7 +110,7 @@
 	restart
 	;;
 condrestart)
-	if [ -f /var/lock/subsys/${MBE_PROG} ]; then
+	if [ -f ${LOCKFILE} ]; then
 	    restart
 	fi
 	;;
