summaryrefslogtreecommitdiff
blob: 19278c5658d37592a3422c93e43e4adcad9ae610 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/sbin/openrc-run
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

depend() {
	use logger
	need net
}

checkconfig() {
	local mod
	if [ -n "${TPM_MODULES}" ] ; then
		for mod in ${TPM_MODULES} ; do
			lsmod | grep -q "^${mod}\b" \
				|| modprobe ${mod} &>/dev/null \
				|| ewarn "Failed to load module ${mod}"
		done
		# Should we sleep or something to wait for device creation?
	fi
	if [ ! -c /dev/tpm ] && [ ! -c /dev/tpm0 ] ; then
		eerror "No TPM device found!"
		return 1
	fi
	return 0
}

start() {
	ebegin "Starting TrouSerS' TCS daemon (tcsd)"
	checkconfig || eend $?
	start-stop-daemon --start --user tss --exec /usr/sbin/tcsd
	eend $?
}

stop() {
	ebegin "Stopping TrouSerS' TCS daemon (tcsd)"
	start-stop-daemon --stop --quiet --exec /usr/sbin/tcsd --user tss
	eend $?
}