index : builder | |
Archlinux32 build system | gitolite user |
summaryrefslogtreecommitdiff |
-rwxr-xr-x | bin/update-gpg-keys | 40 |
diff --git a/bin/update-gpg-keys b/bin/update-gpg-keys new file mode 100755 index 0000000..7e42291 --- /dev/null +++ b/bin/update-gpg-keys @@ -0,0 +1,40 @@ +#!/bin/sh + +# shellcheck source=../lib/load-configuration +. "${0%/*}/../lib/load-configuration" + +if [ $# -ne 0 ]; then + >&2 echo 'error: No arguments expected, but some were given.' + exit 1 +fi + +# shellcheck disable=SC2016 +{ + printf 'SELECT' + printf ' `gpg_keys`.`fingerprint`,' + printf 'replace(to_base64(`gpg_keys`.`public_key`),"\\n","")' + printf ' FROM `gpg_keys`' +} \ +| mysql_run_query \ +| while read -r fingerprint public_key; do + printf '%s\n' "${public_key}" \ + | base64 -d \ + | gpg --import \ + >/dev/null 2>&1 + gpg --quiet --locate-keys "${fingerprint}" \ + >/dev/null 2>&1 \ + || true + curl -Ss 'https://archlinux32.org/keys.php?k='"${fingerprint}" \ + | gpg --import --quiet \ + >/dev/null 2>&1 \ + || true + printf 'UPDATE `gpg_keys`' + printf ' SET `gpg_keys`.`public_key`=from_base64("%s")' \ + "$( + gpg -a --export "${fingerprint}" \ + | base64 -w0 + )" + printf ' WHERE `gpg_keys`.`fingerprint`="%s";\n' \ + "${fingerprint}" +done \ +| mysql_run_query |