Skip to content

Instantly share code, notes, and snippets.

@erikankrom
Forked from Chaz6/renew-letsencrypt-unifi.bash
Last active February 22, 2017 03:21
Show Gist options
  • Save erikankrom/5186d6e5f2da3343592759c4d04a59fb to your computer and use it in GitHub Desktop.
Save erikankrom/5186d6e5f2da3343592759c4d04a59fb to your computer and use it in GitHub Desktop.
#!/bin/bash
NAME="unifi.example.com"
/usr/bin/letsencrypt renew
if test $(find /etc/letsencrypt/live/$NAME/cert.pem -mmin -60)
then
/bin/systemctl stop unifi.service
/usr/bin/openssl pkcs12 -export -inkey /etc/letsencrypt/live/$NAME/privkey.pem -in /etc/letsencrypt/live/$NAME/fullchain.pem -out /tmp/$NAME.p12 -name ubnt -password pass:temppass
/bin/keytool -importkeystore -deststorepass aircontrolenterprise -destkeypass aircontrolenterprise -destkeystore /opt/UniFi/data/keystore -srckeystore /tmp/$NAME.p12 -srcstoretype PKCS12 -srcstorepass temppass -alias ubnt -noprompt
/bin/rm -f /tmp/$NAME.p12
/bin/systemctl start unifi.service
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment