summaryrefslogtreecommitdiff
path: root/scripts/update-trust
diff options
context:
space:
mode:
authorBjörn Mattsson <bjorn@sunet.se>2023-03-06 11:22:05 +0100
committerBjörn Mattsson <bjorn@sunet.se>2023-03-06 11:22:05 +0100
commit467dbdbf3d7212e25ee69daeaadd8adba7c7c5b8 (patch)
treed3576d5f2d4b5cc676c0a12ef8f8c3c83b474bf5 /scripts/update-trust
parentbc1d55080e5d42e6ef2bba892d640aa8f68bbc90 (diff)
Moved files to make ths repo signed
Diffstat (limited to 'scripts/update-trust')
-rwxr-xr-xscripts/update-trust29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/update-trust b/scripts/update-trust
new file mode 100755
index 00000000..bffeaa1b
--- /dev/null
+++ b/scripts/update-trust
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+export GNUPGHOME=/etc/metadata/gnupg
+mkdir -p $GNUPGHOME
+chmod 0700 $GNUPGHOME
+export GPG=gpg
+
+# Install new keys discovered in the keys directory
+for k in keys/*.pub; do
+ fp=`$GPG --with-colons --with-fingerprint --show-key < $k | awk -F: '$1 == "pub" {print $5}'`
+ fp_in_db=`$GPG --with-colons --fingerprint | grep ":$fp:"`
+ if [ "x`echo $fp_in_db | grep '^pub:e:'`" != "x" ]; then
+ echo "$0: Key expired, will re-import it from $k"
+ $GPG --fingerprint $fp
+ fi
+ # The removal of any ^pub:e: entrys means to ignore expired keys - thereby importing them again.
+ echo $fp_in_db | grep -v "^pub:e:" | grep -q ":$fp:" || $GPG --import < $k
+done
+
+# Delete keys no longer present in keys directory
+for fp in `$GPG --with-colons --fingerprint | awk -F: '$1 == "pub" {print $5}'`; do
+ seen="no"
+ for k in keys/*.pub; do
+ $GPG --with-colons --with-fingerprint --show-key < $k | grep -q ":$fp:" && seen="yes"
+ done
+ if [ "x$seen" = "xno" ]; then
+ $GPG --yes --batch --delete-key $fp || true
+ fi
+done