github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/go/run/scripts/run_tpm2.sh (about) 1 #!/bin/bash 2 3 if [ "$#" -ge 1 ]; then 4 export DOMAIN_TEMPLATE="$1" 5 elif [ "$DOMAIN_TEMPLATE" == "" ]; then 6 echo "Must supply the path to a domain template, or set \$DOMAIN_TEMPLATE." 7 exit 1 8 fi 9 10 set -o nounset 11 set -o errexit 12 13 gowhich() { 14 WHICH=$(which which) 15 echo -n "$(PATH="${GOPATH//://bin:}/bin" $WHICH "$1")" 16 } 17 18 TAO="$(gowhich tao)" 19 ENDORSEMENT="$(gowhich Endorsement)" 20 QUOTE="$(gowhich QuoteServer)" 21 FAKE_PASS=BogusPass 22 DOMAIN_TEMPLATE="$(readlink -f $DOMAIN_TEMPLATE)" 23 24 # Make sure we have sudo privileges before trying to start the tao host 25 sudo test true 26 27 # Create new domain 28 if [ -d /tmp/temp_domain ]; then 29 echo "Error: Tao domain directoty /tmp/temp_domain already exists." 30 exit 1 31 fi 32 mkdir /tmp/temp_domain 33 cd /tmp/temp_domain 34 "$TAO" domain init -tao_domain . -pass $FAKE_PASS -config_template $DOMAIN_TEMPLATE 35 36 if [ ! -d ./policy_keys ]; then 37 echo "Error: Policy key not found" 38 exit 1 39 fi 40 echo "Policy key created" 41 42 # Create endorsement cert 43 sudo $ENDORSEMENT -policy_key_is_ecdsa -policy_key_dir ./policy_keys -endorsement_save_file endorsement_cert -policy_key_password $FAKE_PASS 44 45 if [ ! -f ./endorsement_cert ]; then 46 echo "Error: Endorsement cert not found" 47 exit 1 48 fi 49 50 # Start Quote Server 51 $QUOTE -pass $FAKE_PASS -path ./policy_keys & 52 echo 53 echo "Quote server running" 54 55 # Start host 56 sudo "$TAO" host init -tao_domain . -stacked -parent_type TPM2 -hosting process 57 sudo "$TAO" host start -tao_domain . & 58 59 echo 60 echo "Remember to flush open TPM handles, kill the host and Quote server, and remove /tmp/temp_domain" 61 62 63 64 65