#!/bin/bash

NOTIFY='edv@schlittermann.de'
WARNTIME=$(expr 30 \* 24 \* 60 \* 60) # seconds
EXPIRY=$(date -d $(LC_ALL= LANG= gpg -k --with-colons apt.schlittermann.de|grep '^pub'|cut -d: -f7) +%s)
TODAY=$(date +%s)

if [[ $(( $EXPIRY - $TODAY )) -le $WARNTIME ]]; then
  ( echo Subject: apt.schlittermann.de Archive Signing Key is about to expire - please extend expiry date; gpg -k apt.schlittermann.de ) | /usr/sbin/sendmail $NOTIFY
fi
