-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add execution logs in clear_tpm_nv.sh
Signed-off-by: Shrikant Temburwar <shrikant.temburwar@intel.com>
- Loading branch information
1 parent
c3ab532
commit 936a824
Showing
1 changed file
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" |