-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathgenerate-gpg-dir.sh
More file actions
executable file
·31 lines (24 loc) · 968 Bytes
/
generate-gpg-dir.sh
File metadata and controls
executable file
·31 lines (24 loc) · 968 Bytes
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
#!/bin/sh
set -ex
GNUPGHOME=${1:-"$(cd "$(dirname "$0")"; pwd)/gpg"}
ONLY_ACTIVE_KEYS=${2:-"$GNUPGHOME-only-active-keys"}
if [ -d "$GNUPGHOME" ]; then
# If folder exists, move it to a temp dir
# Removing it could be dangerous
TRASH=$(mktemp -d)
mv "$GNUPGHOME" "$TRASH"
fi
if [ -d "$ONLY_ACTIVE_KEYS" ]; then
# If folder exists, move it to a temp dir
# Removing it could be dangerous
TRASH=$(mktemp -d)
mv "$ONLY_ACTIVE_KEYS" "$TRASH"
fi
mkdir -p "$GNUPGHOME"
awk -F'`' '/^<!-- Active releasers keys -->$/,/^<!-- .Active releasers keys -->$/ {if($1 == " [") print substr($3, 3, length($3) - 3) }' README.md | while read -r KEY_PATH; do
GNUPGHOME="$GNUPGHOME" gpg --import "$KEY_PATH"
done
cp -R "$GNUPGHOME" "$ONLY_ACTIVE_KEYS"
awk -F'`' '/^<!-- Retired keys -->$/,/^<!-- .Retired keys -->$/ {if($1 == " [") print substr($3, 3, length($3) - 3) }' README.md | while read -r KEY_PATH; do
GNUPGHOME="$GNUPGHOME" gpg --import "$KEY_PATH"
done