Pramod Raghavendra Jayathirth | 51449da | 2018-08-02 10:41:31 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | echo "Shared volume is ${ABRMD_DATA}" |
| 6 | FILE="${ABRMD_DATA}/tpm_status.yaml" |
| 7 | if [ -f $FILE ];then |
| 8 | flag=$(echo "$(cat ${ABRMD_DATA}/tpm_status.yaml)" | sed '/^flag/{s/[^0-9,]//g;y/,/\n/;}') |
| 9 | if [ "$flag" == 0 ];then |
| 10 | # Start DBUS |
| 11 | mkdir -p /var/run/dbus |
| 12 | stdbuf -oL -eL dbus-daemon --system --nofork 2>&1 1> /var/log/dbus-daemon.log & |
| 13 | # Time for Daemon to start before executin next step |
| 14 | sleep 1m |
| 15 | # Start Resource Manager |
| 16 | if [ -z $TPM_SIMULATOR ]; then |
| 17 | echo "Using TPM Hardware for the operations" |
| 18 | tpm2-abrmd & |
| 19 | # Time for abrmd process to start |
| 20 | sleep 1m |
| 21 | state=$( ps aux | grep tpm2-abrmd | grep -v grep ) |
| 22 | echo "Staus of abrmd Process is $state" |
| 23 | else |
| 24 | echo "Using TPM Simulator for the opeations"; |
| 25 | hostip=$(ip route show | awk '/default/ {print $3}'); |
| 26 | echo "Connecting to $hostip\n"; |
| 27 | tpm2-abrmd -a $hostip -t socket& |
| 28 | fi |
| 29 | |
| 30 | /abrmd/bin/initialize_tpm.sh |
| 31 | status=$? |
| 32 | if [ $status -eq "0" ]; then |
| 33 | echo "TPM Initialization successful $status" |
| 34 | fi |
| 35 | exit $? |
| 36 | else |
| 37 | echo "TPM is already Initialized" |
| 38 | exit; |
| 39 | fi |
| 40 | else |
| 41 | echo " TPM Status file not found, Hence exiting" |
| 42 | exit; |
| 43 | fi |