Blob Blame History Raw
--- dist/fedora/fedora.initrd.tcsd.orig	2010-05-01 13:16:32.000000000 +0200
+++ dist/fedora/fedora.initrd.tcsd	2010-05-01 13:16:53.000000000 +0200
@@ -1,51 +1,46 @@
 #!/bin/bash
 #
-# Init file for the TrouSerS TCG Core Services daemon
+# tcsd Init script for the TrouSerS TCG Core Services daemon
 #
 # chkconfig: - 90 10
 # description: TrouSerS server daemon
-#
-# processname: tcsd
-# config: /etc/tcsd.conf
-# pidfile: /var/run/tcsd.pid
-#
-# Return values according to LSB for all commands but status:
-# 0 - success
-# 1 - generic or unspecified error
-# 2 - invalid or excess argument(s)
-# 3 - unimplemented feature (e.g. "reload")
-# 4 - insufficient privilege
-# 5 - program is not installed
-# 6 - program is not configured
-# 7 - program is not running
-#
 
+### BEGIN INIT INFO
+# Provides: 
+# Required-Start: 
+# Required-Stop: 
+# Should-Start: 
+# Should-Stop: 
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Init script for TCSD
+# Description:	TrouSerS TCG Core Services daemon  
+### END INIT INFO
+
+exec="/usr/sbin/tcsd"
 prog="tcsd"
+config="/etc/tcsd.conf"
+PID_FILE="/var/run/tcsd.pid"
+INSMOD="/sbin/insmod"
+LSMOD="/sbin/lsmod"
+GREP="/bin/grep"
 
 # source function library
 . /etc/rc.d/init.d/functions
 
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
 # Allow anyone to run status
-if [ "$1" = "status" ] ; then
-	status $prog
+if [ "$1" = "status" -o "$1" = "rh_status" -o "$1" = "rh_status_q" ] ; then
+	$1 $prog
 	RETVAL=$?
 	exit $RETVAL
 fi
 
 # Check that we are root ... so non-root users stop here
-test $EUID = 0  ||  exit 4
-
-# pull in sysconfig settings
-test -f /etc/sysconfig/tcsd  && . /etc/sysconfig/tcsd
-
-RETVAL=0
-
-# Some variables to make the below more readable
-TCSD=/usr/sbin/tcsd
-PID_FILE=/var/run/tcsd.pid
-INSMOD=/sbin/insmod
-LSMOD=/sbin/lsmod
-GREP=/bin/grep
+test $EUID = 0	||	exit 4
 
 load_drivers()
 {
@@ -64,14 +59,15 @@
 
 start()
 {
-	test -x $TCSD || exit 5
-	test -f /etc/tcsd.conf || exit 6
+	test -x $exec || exit 5
+	test -f $config || exit 6
 	check_drivers || load_drivers || failure
 	echo -n $"Starting $prog: "
-	$TCSD $OPTIONS && success || failure
+	$exec $OPTIONS && success || failure
 	RETVAL=$?
-	[ "$RETVAL" = 0 ] && touch /var/lock/subsys/tcsd
 	echo
+	[ "$RETVAL" = 0 ] && touch $lockfile
+	return $RETVAL
 }
 
 stop()
@@ -79,32 +75,59 @@
 	echo -n $"Stopping $prog: "
 	killproc $prog
 	RETVAL=$?
-	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/tcsd
 	echo
+	[ "$RETVAL" = 0 ] && rm -f $lockfile
+	return $RETVAL
+}
+
+restart() {
+	stop
+	start
 }
 
+reload() {
+	restart
+}
+
+force_reload() {
+	restart
+}
+
+rh_status() {
+	# run checks to determine if the service is running or use generic status
+	status $prog
+}
+
+rh_status_q() {
+	rh_status >/dev/null 2>&1
+}
+
+
 case "$1" in
 	start)
-		start
+		rh_status_q && exit 0
+		$1
 		;;
 	stop)
-		stop
+		rh_status_q || exit 0
+		$1
 		;;
 	restart)
-		test -f /etc/tcsd.conf  || exit 6
-		stop
-		start
+		$1
 		;;
-	reload|force-reload)
-		restart
+	reload)
+		rh_status_q || exit 7
+        $1
 		;;
+	force-reload)
+        force_reload
+        ;;
 	condrestart|try-restart)
-		if [ -f /var/lock/subsys/tcsd ] ; then
-			restart
-		fi
+		rh_status_q || exit 0
+        restart
 		;;
 	*)
-		echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}"
-		RETVAL=3
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+        exit 2
 esac
-exit $RETVAL
+exit $?