Utilities: Clean up keys after done with signing vault
@@ -5,7 +5,12 @@ abort() {
exit 1
}
-if [ ! -x /usr/bin/dirname ] || [ ! -x /bin/chmod ] || [ ! -x /bin/mkdir ] || [ ! -x /usr/bin/openssl ] || [ ! -x /bin/rm ] || [ ! -x /usr/bin/strings ] || [ ! -x /usr/bin/grep ] || [ ! -x /usr/bin/cut ] || [ ! -x /bin/dd ] ; then
+cleanup() {
+ echo "Cleaning up keys"
+ rm -rf "${KeyPath}"
+}
+
+if [ ! -x /usr/bin/dirname ] || [ ! -x /bin/chmod ] || [ ! -x /bin/mkdir ] || [ ! -x /usr/bin/openssl ] || [ ! -x /bin/rm ] || [ ! -x /usr/bin/strings ] || [ ! -x /usr/bin/grep ] || [ ! -x /usr/bin/cut ] || [ ! -x /bin/dd ] || [ ! -x /usr/bin/uuidgen ] ; then
abort "Unix environment is broken!"
fi
@@ -17,7 +22,7 @@ if [ "$OCPath" = "" ]; then
OCPath=../../EFI/OC
fi
-KeyPath="${OCPath}/Keys"
+KeyPath="/tmp/Keys-$(/usr/bin/uuidgen)"
OCBin="${OCPath}/OpenCore.efi"
RootCA="${KeyPath}/ca.pem"
PrivKey="${KeyPath}/privatekey.cer"
@@ -45,6 +50,8 @@ if [ ! -x ./RsaTool ] || [ ! -x ./create_vault.sh ]; then
fi
fi
+trap cleanup EXIT INT TERM
+
if [ ! -d "${KeyPath}" ]; then
/bin/mkdir -p "${KeyPath}" || abort "Failed to create path ${KeyPath}"
fi
