Last active
March 22, 2018 15:26
-
-
Save dangtrinhnt/5d93df60104ed1d41cd6b33e87e3b801 to your computer and use it in GitHub Desktop.
Renew standalone let's encrypt cert shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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