1#!/bin/sh
2
3### BEGIN INIT INFO
4# Provides:		tcsd trousers
5# Required-Start:	$local_fs $remote_fs $network
6# Required-Stop:	$local_fs $remote_fs $network
7# Should-Start:
8# Should-Stop:
9# Default-Start:	2 3 4 5
10# Default-Stop:		0 1 6
11# Short-Description:	starts tcsd
12# Description:		tcsd belongs to the TrouSerS TCG Software Stack
13### END INIT INFO
14
15PATH=/sbin:/bin:/usr/sbin:/usr/bin
16DAEMON=/usr/sbin/tcsd
17NAME=tcsd
18DESC="Trusted Computing daemon"
19USER="tss"
20
21test -x "${DAEMON}" || exit 0
22
23# Read configuration variable file if it is present
24[ -r /etc/default/$NAME ] && . /etc/default/$NAME
25
26case "${1}" in
27	start)
28		echo "Starting $DESC: "
29
30		if [ ! -e /dev/tpm* ]
31		then
32			echo "device driver not loaded, skipping."
33			exit 0
34		fi
35
36		start-stop-daemon --start --quiet --oknodo \
37			--pidfile /var/run/${NAME}.pid --make-pidfile --background \
38			--user ${USER} --chuid ${USER} \
39			--exec ${DAEMON} -- ${DAEMON_OPTS} --foreground
40		RETVAL="$?"
41		echo "$NAME."
42		exit $RETVAL
43		;;
44
45	stop)
46		echo "Stopping $DESC: "
47
48		start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/${NAME}.pid --user ${USER} --exec ${DAEMON}
49		RETVAL="$?"
50                echo  "$NAME."
51		rm -f /var/run/${NAME}.pid
52		exit $RETVAL
53		;;
54
55	restart|force-reload)
56		"${0}" stop
57		sleep 1
58		"${0}" start
59		exit $?
60		;;
61	*)
62		echo "Usage: ${NAME} {start|stop|restart|force-reload|status}" >&2
63		exit 3
64		;;
65esac
66
67exit 0
68