3 # Purpose: set up a system for use with TPM technology
4 # Authors: (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 ################################################################################
9 . /etc/grml/lsb-functions
11 if [ $UID != 0 ] ; then
12 eerror Error: become root before starting $0 >& 2 ; eend 1
17 TPM_MODULES=$(awk '/tpm/ {print $1}' /proc/modules | xargs echo -n)
21 # tpm_emulator registers as /sys/class/misc/tpm while
22 # real tpm modules should provide /sys/class/misc/tpm0
23 if [ -d /sys/class/misc/tpm0 ] ; then
24 ewarn "TPM kernel modules $TPM_MODULES seem to be loaded already." ; eend 0
26 if ! modinfo tpm_emulator &>/dev/null ; then
27 eerror "Error: kernel module tpm_emulator not found." >& 2
28 eerror "Check for an existing debian package or get it from http://tpm-emulator.berlios.de/" >& 2
32 if grep -q tpm_emulator /proc/modules ; then
33 ewarn "Kernel driver tpm_emulator already loaded." ; eend 0
35 einfo "Loading kernel driver tpm_emulator."
36 modprobe tpm_emulator startup=clear ; eend $?
40 if [ -x /usr/sbin/tcsd ] ; then
41 if pidof tcsd &>/dev/null ; then
42 ewarn "trousers daemon already running." ; eend 0
44 einfo "Starting trousers daemon."
45 /usr/sbin/tcsd ; eend $?
49 eerror "trousers daemon not available. Exiting." ; eend 1
53 einfo "Startup of $PN finished." ; eend 0
56 if pidof tcsd &>/dev/null ; then
57 einfo "Stopping trousers daemon."
58 kill `pidof tcsd` ; eend $?
60 ewarn "No running trousers daemon found. Nothing to be done." ; eend 0
63 if grep -q tpm_emulator /proc/modules ; then
64 einfo "Unloading kernel driver tpm_emulator."
65 rmmod tpm_emulator ; eend $?
66 elif grep -q tpm /proc/modules ; then
67 einfo "Unloading TPM kernel drivers $(awk '/tpm/ {print $1}' /proc/modules | xargs echo -n)."
68 while grep -q tpm /proc/modules ; do
69 for module in $(cd /lib/modules/$(uname -r)/kernel/drivers/char/tpm/ ; ls *.ko) ; do
70 rmmod ${module%%.ko} &>/dev/null
75 ewarn "No TPM kernel driver found. Nothing to be done." ; eend 0
79 if [ -r /sys/class/misc/tpm ] ; then
80 einfo "Seems to be running with tpm_emulator." ; eend 0
83 if [ -r /sys/class/misc/tpm0 ] ; then
84 einfo "Seems to be running with real TPM hardware." ; eend 0
87 if pidof tcsd &>/dev/null ; then
88 einfo "trousers daemon running." ; eend 0
89 if [ -x /usr/sbin/tpm_version ] ; then
93 eerror "tpm_version not found." ; eend 1
96 ewarn "trousers daemon not running." ; eend 0
99 if [ -r /sys/class/misc/tpm0/device/pcrs ] ; then
100 einfo "Dumping PCRS..."
101 cat /sys/class/misc/tpm0/device/pcrs ; RC=$?
102 einfo "... finished dumping of PCRS." ; eend $RC
106 $0 stop ; sleep 1 ; $0 start
109 eerror "Usage: $PN [start|stop|restart|status]"
113 ## END OF FILE #################################################################