Last active
January 18, 2024 00:28
-
-
Save mscalora/94f384d1311f66ac09ea6d31d77a102e to your computer and use it in GitHub Desktop.
script to auto update letsencrypt certs for debian lighttpd installation (based on script by Danny Tuppeny)
This file contains 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
#!/usr/bin/env bash | |
# | |
# Update letsencrypt on a lighttp installation | |
# | |
# if you installed letsencrypt in a non-standard location you | |
# can set the LEDIR env var before you run this script | |
# | |
# setup letsencrypt install directory | |
STDLEDIR=/opt/letsencrypt | |
LEDIR=${LEDIR:-$STDLEDIR} | |
echo "##### Starting renewal $(date) at $LEDIR #####" | |
# check path to letsencrypt-auto tool | |
if [ ! -f "$LEDIR/letsencrypt-auto" ]; then | |
echo "Error: letsencrypt-auto script not found, is letsencrypt installed at $LEDIR?" | |
exit 1 | |
fi | |
# renew all certs in live directory | |
$LEDIR/letsencrypt-auto renew | |
# rebuild the cert combined.pem | |
for domain in /etc/letsencrypt/live/* ; do | |
pushd $domain | |
echo "Rebuilding cert for: $(basename $domain)" | |
cat privkey.pem cert.pem > combined.pem | |
popd | |
done | |
# reload lighttpd | |
/etc/init.d/lighttpd force-reload | |
echo "##### Finished renewal $(date) at $LEDIR #####" | |
exit 0 | |
# recommended cron installation (run crontab -e as root) | |
30 2 * * 1 <abs-path>/letsencrypt-update-lighttpd >> /var/log/le-renew.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created a fork: https://gist.github.com/qwertychouskie/065007bdfcf58b6c4e8354ac60cd587e
Useful if you use the packaged version from jessie-backports.