Skip to content

Instantly share code, notes, and snippets.

@rwmotivation
Forked from ntotten/certrenew.sh
Created December 4, 2020 08:35
Show Gist options
  • Save rwmotivation/c31523368c2c22ce055a8dad2b98c5b4 to your computer and use it in GitHub Desktop.
Save rwmotivation/c31523368c2c22ce055a8dad2b98c5b4 to your computer and use it in GitHub Desktop.
Script to renew Let's Encrypt certificate and then replace certificate on OpenVPN server
#!/bin/bash
(
DOMAIN="vpn.example.com"
set -eu
certbot renew -q
/usr/local/openvpn_as/scripts/sacli stop
/usr/local/openvpn_as/scripts/confdba -mk cs.ca_bundle -v "`cat /etc/letsencrypt/live/$DOMAIN/fullchain.pem`"
/usr/local/openvpn_as/scripts/confdba -mk cs.priv_key -v "`cat /etc/letsencrypt/live/$DOMAIN/privkey.pem`" > /dev/null
/usr/local/openvpn_as/scripts/confdba -mk cs.cert -v "`cat /etc/letsencrypt/live/$DOMAIN/cert.pem`"
/usr/local/openvpn_as/scripts/sacli start
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment