Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mscalora
Last active January 18, 2024 00:28
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mscalora/94f384d1311f66ac09ea6d31d77a102e to your computer and use it in GitHub Desktop.
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)
#!/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
@qwertychouskie
Copy link

Created a fork: https://gist.github.com/qwertychouskie/065007bdfcf58b6c4e8354ac60cd587e
Useful if you use the packaged version from jessie-backports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment