aboutsummaryrefslogtreecommitdiff
blob: 405b67f2c6c78c840b74bbc381945be3ff4c7b54 (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
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

description="Manages the Trusted Platform Module emulator service"

depend() {
	use logger
	after coldplug
}

checkconfig() {
	lsmod | grep -q "^tpmd_dev\b" \
		|| modprobe tpmd_dev &>/dev/null \
		|| eerror "Failed to load module tpmd_dev";

	if [ ! -c /dev/tpm ] && [ ! -c /dev/tpm0 ] ; then
		eerror "No TPM device found!"
		return 1
	fi
	return 0
}

start() {
	ebegin "Starting tpm-emulator daemon with mode '$STARTUP_MODE' (tpmd)"
	checkconfig || eend $?
	start-stop-daemon --start --user tss --exec /usr/bin/tpmd $STARTUP_MODE > /dev/null
	eend $?
}

stop() {
	ebegin "Stopping tpm-emulator daemon (tpmd)"
	start-stop-daemon --stop --exec /usr/bin/tpmd --user tss > /dev/null
	eend $?
}