Skip to content

Commit

Permalink
Add execution logs in clear_tpm_nv.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Shrikant Temburwar <shrikant.temburwar@intel.com>
  • Loading branch information
shrikant1407 committed Jan 11, 2024
1 parent c3ab532 commit 936a824
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion utils/clear_tpm_nv.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
#!/bin/bash

execute_cmd_on_failure_exit()
{
eval exec_cmd="$1"
eval success_msg="$2"
eval failure_msg="$3"

echo -e "\e[2;33mExecuting :\e[0m ${exec_cmd}"
out=$(eval ${exec_cmd}" 2>&1")
if [ `echo $?` != 0 ]; then
echo -e "\e[2;31m${failure_msg}\e[0m"
else
echo -e "\e[2;32m${success_msg}\e[0m"
fi

return 0
}

for n in {1..9};
do
tpm2_nvundefine $n
task="Deleting a Non-Volatile (NV) index at 0x100000$n"
cmd="tpm2_nvundefine 0x100000$n"
success_string="$task completed successfully!!"
failure_string="Non-Volatile (NV) index at 0x100000$n is not defined!!"
execute_cmd_on_failure_exit "\$cmd" "\$success_string" "\$failure_string"
done
echo "TPM NV storage cleared!"

0 comments on commit 936a824

Please sign in to comment.