diff options
Diffstat (limited to 'opt/tests/assert-gpg-expiration.sh')
-rwxr-xr-x | opt/tests/assert-gpg-expiration.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/opt/tests/assert-gpg-expiration.sh b/opt/tests/assert-gpg-expiration.sh new file mode 100755 index 0000000..d17486e --- /dev/null +++ b/opt/tests/assert-gpg-expiration.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -eu + + +SECRET_KEY='81F90EC3CD356060' +NEXT_6_MONTHS="$(echo "$(date '+%s') + (60 * 60 * 24 * 30 * 6)" | bc)" + +gpg --with-colons --fixed-list-mode --list-keys "$SECRET_KEY" | + grep -e ^pub -e ^sub | + while read -r subkey; do + EXPIRY="$(echo "$subkey" | cut -d: -f7)" + if [ -z "$EXPIRY" ]; then + continue + fi + + if [ "$EXPIRY" -gt "$(date '+%s')" ] && + [ "$EXPIRY" -lt "$NEXT_6_MONTHS" ]; then + printf 'Key %s to expire soon!.\n' \ + "$(echo "$subkey" | cut -d: -f5)" >&2 + exit 1 + fi + done |