Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2021-01-22 09:50:31 +0100
committerErich Eckner <git@eckner.net>2021-01-22 09:50:31 +0100
commit3d688b2d0aa547e80dc25c98a3bd39bb57eaaecb (patch)
tree588340401b578bccb772ca14778984b99cb4326b
parent60abcbf00dfcda7a9552992c17730d019ae9ea3f (diff)
bin/update-gpg-keys new: refresh local-keyring keys and keys in mysql from each other and archlinux32.org/keys.php and wkd
-rwxr-xr-xbin/update-gpg-keys40
1 files changed, 40 insertions, 0 deletions
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