Skip to content

Instantly share code, notes, and snippets.

@dstokes
Last active January 1, 2016 17:55
Show Gist options
  • Save dstokes/f99a5f49fe8e97fa71de to your computer and use it in GitHub Desktop.
Save dstokes/f99a5f49fe8e97fa71de to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Update SSL certs with letsencrypt
#
LE_HOME=/usr/src/letsencrypt
# stop nginx temporarily
echo "Stopping nginx"
systemctl stop nginx
# write cert to /etc/letsencrypt/live/my.domain.com/
$LE_HOME/letsencrypt-auto certonly \
--standalone \
--standalone-supported-challenges tls-sni-01 \
--renew-by-default \
-d my.domain.com
EXIT_CODE=0
if [[ $? -ne 0 ]]; then
echo "Failed to generate new SSL cert"
EXIT_CODE=1
fi
echo "Starting nginx"
systemctl start nginx
exit $EXIT_CODE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment