Skip to content

Instantly share code, notes, and snippets.

@dangtrinhnt
Last active March 22, 2018 15:26
Show Gist options
  • Save dangtrinhnt/5d93df60104ed1d41cd6b33e87e3b801 to your computer and use it in GitHub Desktop.
Save dangtrinhnt/5d93df60104ed1d41cd6b33e87e3b801 to your computer and use it in GitHub Desktop.
Renew standalone let's encrypt cert shell script
#! /bin/bash
## Because this is a standalone letsencrypt cert
## We have to stop nginx before doing renewal
CERT_IS_VALID=$(/usr/bin/ssl-cert-check -c /etc/letsencrypt/live/mydomain.com/fullchain.pem)
VALID_STR="Valid"
if [[ "$CERT_IS_VALID" =~ "$VALID_STR" ]];
then
echo "Cert is valid"
else
echo "\n=== Cert is expired ===\n"
systemctl stop nginx
/usr/bin/certbot renew
systemctl start nginx
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment