-
Notifications
You must be signed in to change notification settings - Fork 4
/
keys.sh
executable file
·55 lines (50 loc) · 1.74 KB
/
keys.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Define the directory to be listed; default to secure-boot if none provided
directory="${1:-secure-boot}"
# Print the root directory
echo "$(basename "$(realpath "$directory")")/"
# Function to generate tree view and add comments to specific files
generate_tree() {
find "$directory" -mindepth 1 -print | sort | sed 's|[^/]*/| |g' | awk '
{
# Replace leading spaces with a combination of pipes and dashes to simulate tree branches
gsub(/ /, "| ", $0);
sub(/\| $/, "`---", $0);
print;
}'
}
# Function to add comments to specific files
function add_comment {
while read -r line; do
# Determine filename from the indented line
filename="${line##* }" # Extract the last part after space, which should be the file name
case "$filename" in
"PK.auth"*)
echo "$line <-- Platform Key"
;;
"KEK.auth"*)
echo "$line <-- Key Exchange Key"
;;
"db.auth"*)
echo "$line <-- Signature Database"
;;
"dbx.auth"*)
echo "$line <-- Forbidden Signatures Database"
;;
"PK.key"*)
echo "$line <-- Remove me from this directory and keep me safe"
;;
"KEK.key"*)
echo "$line <-- Remove me from this directory and keep me safe"
;;
"tpm2-pcr-private.pem"*)
echo "$line <-- Don't lose me! Without me you lose access to your encrypted disks"
;;
*)
echo "$line"
;;
esac
done
}
# Generate the tree and pipe it to add comments
generate_tree | add_comment