drive-ops/global/post-tasks.d/015cosmos-trust

29 lines
1 KiB
Plaintext
Raw Normal View History

2013-09-02 14:01:50 +00:00
#!/bin/sh
2013-10-31 21:20:33 +00:00
if [ -z "$COSMOS_KEYS" ]; then
2013-10-31 21:04:54 +00:00
COSMOS_KEYS=/etc/cosmos/keys
fi
# Install new keys discovered in the $COSMOS_KEYS directory
2013-10-31 21:04:54 +00:00
for k in $COSMOS_KEYS/*.pub; do
fp=`cosmos gpg --with-colons --with-fingerprint < $k | awk -F: '$1 == "pub" {print $5}'`
fp_in_db=`cosmos 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"
cosmos 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:" || cosmos gpg --import < $k
2013-09-02 14:01:50 +00:00
done
# Delete keys no longer present in $COSMOS_KEYS directory
2013-09-02 14:01:50 +00:00
for fp in `cosmos gpg --with-colons --fingerprint | awk -F: '$1 == "pub" {print $5}'`; do
seen="no"
2013-10-31 22:26:16 +00:00
for k in $COSMOS_KEYS/*.pub; do
2013-09-02 14:01:50 +00:00
cosmos gpg --with-colons --with-fingerprint < $k | grep -q ":$fp:" && seen="yes"
done
if [ "x$seen" = "xno" ]; then
cosmos gpg --yes --batch --delete-key $fp || true
fi
done