tpm2_ptool shell script to create primary if it doesn't exist yet
The following shell script checks if a primary object exists in the TPM. If it does not, it initializes the TPM using tpm2_ptool init
. If a primary already exists, it simply outputs a message indicating that.
It doesn’t matter if one or more primaries exist; the script will only initialize if none are found.
if [ -z "$(tpm2_ptool listprimaries)" ]; then
tpm2_ptool init
else
echo "Primary already exists"
fi
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow