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 # Latest change: Mit Jul 26 02:26:06 CEST 2006 [mika]
8 ################################################################################
10 . /etc/grml/lsb-functions
12 if [ $UID != 0 ] ; then
13 eerror Error: become root before starting $0 >& 2 ; eend 1
18 TPM_MODULES=$(awk '/tpm/ {print $1}' /proc/modules | xargs echo -n)
22 # tpm_emulator registers as /sys/class/misc/tpm while
23 # real tpm modules should provide /sys/class/misc/tpm0
24 if [ -d /sys/class/misc/tpm0 ] ; then
25 ewarn "TPM kernel modules $TPM_MODULES seem to be loaded already." ; eend 0
27 if ! modinfo tpm_emulator &>/dev/null ; then
28 eerror "Error: kernel module tpm_emulator not found." >& 2
29 eerror "Check for an existing debian package or get it from http://tpm-emulator.berlios.de/" >& 2
33 if grep -q tpm_emulator /proc/modules ; then
34 ewarn "Kernel driver tpm_emulator already loaded." ; eend 0
36 einfo "Loading kernel driver tpm_emulator."
37 modprobe tpm_emulator startup=clear ; eend $?
41 if [ -x /usr/sbin/tcsd ] ; then
42 if pidof tcsd &>/dev/null ; then
43 ewarn "trousers daemon already running." ; eend 0
45 einfo "Starting trousers daemon."
46 /usr/sbin/tcsd ; eend $?
50 eerror "trousers daemon not available. Exiting." ; eend 1
54 einfo "Startup of $PN finished." ; eend 0
57 if pidof tcsd &>/dev/null ; then
58 einfo "Stopping trousers daemon."
59 kill `pidof tcsd` ; eend $?
61 ewarn "No running trousers daemon found. Nothing to be done." ; eend 0
64 if grep -q tpm_emulator /proc/modules ; then
65 einfo "Unloading kernel driver tpm_emulator."
66 rmmod tpm_emulator ; eend $?
67 elif grep -q tpm /proc/modules ; then
68 einfo "Unloading TPM kernel drivers $(awk '/tpm/ {print $1}' /proc/modules | xargs echo -n)."
69 while grep -q tpm /proc/modules ; do
70 for module in $(cd /lib/modules/$(uname -r)/kernel/drivers/char/tpm/ ; ls *.ko) ; do
71 rmmod ${module%%.ko} &>/dev/null
76 ewarn "No TPM kernel driver found. Nothing to be done." ; eend 0
80 if [ -r /sys/class/misc/tpm ] ; then
81 einfo "Seems to be running with tpm_emulator." ; eend 0
84 if [ -r /sys/class/misc/tpm0 ] ; then
85 einfo "Seems to be running with real TPM hardware." ; eend 0
88 if pidof tcsd &>/dev/null ; then
89 einfo "trousers daemon running." ; eend 0
90 if [ -x /usr/sbin/tpm_version ] ; then
94 eerror "tpm_version not found." ; eend 1
97 ewarn "trousers daemon not running." ; eend 0
100 if [ -r /sys/class/misc/tpm0/device/pcrs ] ; then
101 einfo "Dumping PCRS..."
102 cat /sys/class/misc/tpm0/device/pcrs ; RC=$?
103 einfo "... finished dumping of PCRS." ; eend $RC
107 $0 stop ; sleep 1 ; $0 start
110 eerror "Usage: $PN [start|stop|restart|status]"
114 ## END OF FILE #################################################################