Skip to content

Instantly share code, notes, and snippets.

@Bachsau
Created February 28, 2023 21:15
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 Bachsau/6db3432067b4683d1773c88558ad6a14 to your computer and use it in GitHub Desktop.
Save Bachsau/6db3432067b4683d1773c88558ad6a14 to your computer and use it in GitHub Desktop.
Certbot hooks for etckeeper; place them in /etc/letsencrypt/renewal-hooks/(pre|post)/
#!/bin/sh -eu
# Run etckeeper after certificate renewal (by Bachsau)
if command -v etckeeper >/dev/null && etckeeper unclean; then
etckeeper commit "committing updates to certificate configuration files after renewal"
fi
#!/bin/sh -eu
# Run etckeeper prior to certificate renewal (by Bachsau)
if command -v etckeeper >/dev/null && etckeeper unclean; then
etckeeper commit "saving uncommitted changes in /etc prior to certificate renewal"
fi
@Bachsau
Copy link
Author

Bachsau commented Feb 28, 2023

Note: You need to .gitignore /letsencrypt/.certbot.lock, which only exists while Certbot is running. Also /letsencrypt/archive/ and /letsencrypt/live/ if you want to keep the certs and private keys out of the repository. I'm only versioning the renewal configuration files.

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