aboutsummaryrefslogtreecommitdiff
path: root/opt
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-10-19 13:34:46 -0300
committerEuAndreh <eu@euandre.org>2022-10-19 13:37:06 -0300
commit69d26f531c77bc65eb2fedfe0efd43c67dbbba6f (patch)
treeca39b9f2700f3f100ca50cc0cb563545c113ed45 /opt
parentetc/sh/rc: Move generation of GPG/SSH public keys and e.list.txt to Makefile (diff)
downloaddotfiles-69d26f531c77bc65eb2fedfe0efd43c67dbbba6f.tar.gz
dotfiles-69d26f531c77bc65eb2fedfe0efd43c67dbbba6f.tar.xz
bin/check: Move tests to Makefile
Diffstat (limited to 'opt')
-rwxr-xr-xopt/tests/assert-gpg-expiration.sh22
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