Skip to content

Instantly share code, notes, and snippets.

@adamrunner
Last active April 9, 2024 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamrunner/aaaef0538a07f04a04f4d416a9b00af8 to your computer and use it in GitHub Desktop.
Save adamrunner/aaaef0538a07f04a04f4d416a9b00af8 to your computer and use it in GitHub Desktop.
Shell script to automate installation of new LetsEncrypt certs into OpenVPN Access Server when they have been renewed
#!/bin/bash
# this script is used to update the openvpn access server certificates after
# certbot renews the certificates
# the cron job should be like this:
# certbot renew --deploy-hook /usr/local/bin/update-openvpn-certs.sh
$DOMAIN = "YOUR_DOMAIN_NAME"
./sacli --key "cs.priv_key" --value_file "/etc/letsencrypt/live/$DOMAIN/privkey.pem" ConfigPut
./sacli --key "cs.cert" --value_file "/etc/letsencrypt/live/$DOMAIN/cert.pem" ConfigPut
./sacli --key "cs.ca_bundle" --value_file "/etc/letsencrypt/live/$DOMAIN/chain.pem" ConfigPut
# Restarts openvpn access server service
./sacli start
# test the new certs, this is optional
# ./sacli --ca_bundle=/etc/letsencrypt/live/$DOMAIN/chain.pem --cert=/etc/letsencrypt/live/$DOMAIN/cert.pem --priv_key=/etc/letsencrypt/live/$DOMAIN/privkey.pem TestWebCerts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment