2021-03-15 17:09:32 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# remove any prior TPM contents
|
|
|
|
rm -f NVChip h*.bin *.permall
|
|
|
|
if [ -x "${SWTPM}" ]; then
|
2023-10-05 03:21:35 +02:00
|
|
|
${SWTPM} socket --tpm2 --daemon \
|
|
|
|
--pid file=swtpm.pid \
|
|
|
|
--server type=tcp,port=2321 \
|
|
|
|
--ctrl type=tcp,port=2322 \
|
|
|
|
--flags not-need-init,startup-clear \
|
|
|
|
--tpmstate dir=`pwd`
|
|
|
|
cat swtpm.pid
|
2021-03-15 17:09:32 +01:00
|
|
|
else
|
|
|
|
${TPMSERVER} > /dev/null 2>&1 &
|
2023-10-04 11:30:33 +02:00
|
|
|
pid=$!
|
2023-10-05 03:21:35 +02:00
|
|
|
##
|
|
|
|
# This powers on the tpm and starts it
|
|
|
|
# then we derive the RSA version of the storage seed and
|
|
|
|
# store it permanently at handle 81000001 and flush the transient
|
|
|
|
##
|
|
|
|
a=0
|
|
|
|
while [ $a -lt 10 ]; do
|
|
|
|
tsspowerup > /dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
a=$[$a+1]
|
|
|
|
done
|
|
|
|
if [ $a -eq 10 ]; then
|
|
|
|
echo "Waited 10s for tpm_server to come up; exiting"
|
|
|
|
exit 1
|
2021-03-15 17:09:32 +01:00
|
|
|
fi
|
|
|
|
|
2023-10-05 03:21:35 +02:00
|
|
|
${TSSSTARTUP} || exit 1
|
|
|
|
echo -n $pid
|
|
|
|
fi
|