#!/bin/sh # This file is in the public domain. # Author: Joost van Baal-Ilić, october 2015 # git/ad1810-stuff # a1-certbot-renew-if-needed : call "certbot renew" if we have any chance # on success. also, stop apache as needed on ninsun aka help.013.nl (it'll # get started by certbot). # to be run from cron, e.g. via /etc/cron.weekly/ # root@ninsun:~# certbot certificates 2>/dev/null | grep Expiry # Expiry Date: 2026-01-04 18:41:19+00:00 (VALID: 88 days) daysleft="$( certbot certificates 2>/dev/null | grep Expiry | while read a b c d e f r; do echo $f; done )" if test $daysleft -lt 14 then service apache2 stop certbot --standalone renew else echo a1-certbot-renew-if-needed: still $daysleft days left, not trying renewal yet fi