Originally created by @ghost on GitHub (Dec 2, 2019).
Hello,
Currently, when we want to reload services that are dependent on certificates, we may use the hook script deploy_cert() function. Unfortunately, this means that if the script is renewing multiple certificates, the deploy_cert() function will be called once per domain and thus reload the services multiple times.
Would it be possible to change the exit_hook() function, so that its passed a status parameter that tells if there was at least one certificate that was created/updated, so that the reload of the services only happens once?
exit_hook() {
local STATUS="${1:-}"
if [ ${STATUS} ... ] ...
# at least one domain was created/changed, reload only once
systemctl reload httpd postfix haproxy dovecot
fi
}
Thank you.
Originally created by @ghost on GitHub (Dec 2, 2019).
Hello,
Currently, when we want to reload services that are dependent on certificates, we may use the hook script deploy_cert() function. Unfortunately, this means that if the script is renewing multiple certificates, the deploy_cert() function will be called once per domain and thus reload the services multiple times.
```
deploy_cert() {
local DOMAIN="${1}" KEYFILE="${2}" CERTFILE="${3}" FULLCHAINFILE="${4}" CHAINFILE="${5}" TIMESTAMP="${6}"
echo "Reloading services..."
systemctl reload httpd postfix haproxy dovecot
}
Reloading services...
Reloading services...
Reloading services...
```
Would it be possible to change the exit_hook() function, so that its passed a status parameter that tells if there was at least one certificate that was created/updated, so that the reload of the services only happens once?
```
exit_hook() {
local STATUS="${1:-}"
if [ ${STATUS} ... ] ...
# at least one domain was created/changed, reload only once
systemctl reload httpd postfix haproxy dovecot
fi
}
```
Thank you.
Not saying it wouldn't be nice to have to this as a built-in feature, it's very easy to do it by yourself though. This is how I do it:
at the top of the hook script:
HTTP_RELOAD_TRIGGER="$BASEDIR/.reload_httpd"
in deploy_cert():
echo "*** new cert for $DOMAIN, scheduling httpd reload..."
touch "$HTTP_RELOAD_TRIGGER"
in exit_hook():
if [ -e "$HTTP_RELOAD_TRIGGER" ]; then
echo "*** reloading httpd..."
systemctl reload httpd
rm -f "$HTTP_RELOAD_TRIGGER"
fi
@jahir commented on GitHub (Dec 2, 2019):
Not saying it wouldn't be nice to have to this as a built-in feature, it's very easy to do it by yourself though. This is how I do it:
at the top of the hook script:
```
HTTP_RELOAD_TRIGGER="$BASEDIR/.reload_httpd"
```
in `deploy_cert()`:
```
echo "*** new cert for $DOMAIN, scheduling httpd reload..."
touch "$HTTP_RELOAD_TRIGGER"
```
in `exit_hook()`:
```
if [ -e "$HTTP_RELOAD_TRIGGER" ]; then
echo "*** reloading httpd..."
systemctl reload httpd
rm -f "$HTTP_RELOAD_TRIGGER"
fi
```
I personally use the same method @jahir uses, though not exactly the same (the differences in my case are inconsequential, I still use flag files and test for the existence)
@jobe1986 commented on GitHub (Dec 2, 2019):
I personally use the same method @jahir uses, though not exactly the same (the differences in my case are inconsequential, I still use flag files and test for the existence)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @ghost on GitHub (Dec 2, 2019).
Hello,
Currently, when we want to reload services that are dependent on certificates, we may use the hook script deploy_cert() function. Unfortunately, this means that if the script is renewing multiple certificates, the deploy_cert() function will be called once per domain and thus reload the services multiple times.
Would it be possible to change the exit_hook() function, so that its passed a status parameter that tells if there was at least one certificate that was created/updated, so that the reload of the services only happens once?
Thank you.
@jahir commented on GitHub (Dec 2, 2019):
Not saying it wouldn't be nice to have to this as a built-in feature, it's very easy to do it by yourself though. This is how I do it:
at the top of the hook script:
in
deploy_cert():in
exit_hook():@jobe1986 commented on GitHub (Dec 2, 2019):
I personally use the same method @jahir uses, though not exactly the same (the differences in my case are inconsequential, I still use flag files and test for the existence)
@ghost commented on GitHub (Mar 25, 2020):
no interest, closing