-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bin: Support multiple fingerprints in CK8S_PGP_FP during init
- Loading branch information
Showing
3 changed files
with
34 additions
and
20 deletions.
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
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ gpg.auto_generate_key() { | |
gpg --batch --generate-key <<EOF | ||
Key-Type: RSA | ||
Key-Length: 4096 | ||
Name-Real: Welkin / Apps / Tests | ||
Name-Real: Welkin / Apps / Tests / ${1} | ||
Name-Email: [email protected] | ||
Expire-Date: 1d | ||
%no-protection | ||
|
@@ -16,16 +16,11 @@ Expire-Date: 1d | |
EOF | ||
} | ||
|
||
# Creates a temporary gpg home and generates a temporary key | ||
# CK8S_PGP_FP will be set with the fingerprint | ||
gpg.setup() { | ||
GNUPGHOME="$(mktemp --directory)" | ||
export GNUPGHOME | ||
|
||
gpg.auto_generate_key_retry() { | ||
local n | ||
for n in $(seq 3); do | ||
# Retry as gpg-agent might not reliably start | ||
if gpg.auto_generate_key; then | ||
if gpg.auto_generate_key "${1}"; then | ||
break | ||
fi | ||
echo "failed to generate gpg key try ${n}" >&2 | ||
|
@@ -35,8 +30,18 @@ gpg.setup() { | |
if [[ "${n}" == "0" ]]; then | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Creates a temporary gpg home and generates a temporary key | ||
# CK8S_PGP_FP will be set with the fingerprint | ||
gpg.setup() { | ||
GNUPGHOME="$(mktemp --directory)" | ||
export GNUPGHOME | ||
|
||
gpg.auto_generate_key_retry "Key one" | ||
gpg.auto_generate_key_retry "Key two" | ||
|
||
CK8S_PGP_FP="$(gpg --list-secret-keys --with-colons | grep -A1 '^sec' | grep '^fpr' | awk -F: '{print $10}')" | ||
CK8S_PGP_FP="$(gpg --list-secret-keys --with-colons | grep -A1 '^sec' | grep '^fpr' | awk -F: '{print $10}' | paste -sd "," -)" | ||
export CK8S_PGP_FP | ||
} | ||
|
||
|
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