Created
May 19, 2016 08:24
-
-
Save un1ko85/d962f5d5c26b7d10ce3eadd2a23f465f to your computer and use it in GitHub Desktop.
Letsencrypt FreeBSD deploy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| domain="example.net" | |
| letsencryptdir="/usr/local/etc/letsencrypt.sh" | |
| targets="mail http" | |
| for jail in ${targets}; do | |
| targetdir="/usr/jails/${jail}/etc/ssl" | |
| # Check if the certificate has changed | |
| [ -z "`diff -rq ${letsencryptdir}/certs/${domain}/fullchain.pem ${targetdir}/certs/${domain}.pem`" ] && continue | |
| cp -L "${letsencryptdir}/certs/${domain}/privkey.pem" "${targetdir}/priv/${domain}.pem" | |
| cp -L "${letsencryptdir}/certs/${domain}/fullchain.pem" "${targetdir}/certs/${domain}.pem" | |
| chmod 400 "${targetdir}/priv/${domain}.pem" | |
| chmod 644 "${targetdir}/certs/${domain}.pem" | |
| # Restart/-load relevant services | |
| [ "${jail}" = "http" ] && jexec ${jail} service apache24 restart | |
| [ "${jail}" = "mail" ] && jexec ${jail} service smtpd restart | |
| done | |
| # Clean up old keys and certs | |
| /usr/local/bin/letsencrypt.sh --cleanup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment