Skip to content

Instantly share code, notes, and snippets.

@betapcode
Last active September 4, 2018 02:36
Show Gist options
  • Save betapcode/fb906d2757bad1c071cbf71e5586bfe8 to your computer and use it in GitHub Desktop.
Save betapcode/fb906d2757bad1c071cbf71e5586bfe8 to your computer and use it in GitHub Desktop.
Simple Certbot (Let's Encrypt) script for auto-renewal certificates
#!/bin/bash
# Source
# https://gist.github.com/betapcode/fb906d2757bad1c071cbf71e5586bfe8
# Make sure this is added to the crontab, ie:
# sudo crontab -e
# MAILTO="[email protected]"
# 30 2 * */3 * /opt/certbot-renew.sh
# Config
web_service="nginx";
le_path="/opt";
# Stop nginx service
echo "Stop $web_service"
/sbin/service $web_service stop
# Update the cert
echo "The certificate for domain is about to expire. Starting renewal script..."
$le_path/certbot-auto renew
# Start our service
echo "Start $web_service"
/sbin/service $web_service start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment