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…)
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.: