Howto script certbot running hooks only once

I have some domains with certificates.
Now l want a script which could run only once pre hook (e.g. stop httpd, delete old certs). Then checks/renew all certs. After certbot has all done, then there should be run only one post hook (e.g. restart httpd, postfix, dovecot, copy files…)

Is that possible, perhaps with an example?

Mandy thanks.

If you’re running a recent enough version of certbot, just drop your before script in /etc/letsencrypt/renewal-hooks/pre and your after script in /etc/letsencrypt/renewal-hooks/post.

(If these two directories exist on your system then they’ll work. If they’re not there, it’s too old.)

If you’re running an older version of certbot, you have to instruct certbot to run the hooks when issuing the certificate, e.g.:

certbot certonly --standalone -d, --pre-hook /usr/local/bin/ --post-hook /usr/local/bin/
certbot certonly --standalone -d, --pre-hook /usr/local/bin/ --post-hook /usr/local/bin/

Even though you have to define it for every certificate you want it to run for, certbot will only call it once as long as the commands are identical.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.