diff options
author | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2022-07-07 10:54:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2022-07-07 14:14:23 +0000 |
commit | 858232205dea7a1900dd38a146a6c2e054049c05 (patch) | |
tree | 1e8bad5dbd611a712d321f43ca47486f28050ead /dehydrated/share | |
parent | Adding postfix to service-reload dehydrated hook. (diff) | |
download | service-tools-858232205dea7a1900dd38a146a6c2e054049c05.tar.xz service-tools-858232205dea7a1900dd38a146a6c2e054049c05.zip |
Reworking service-reload dehydrated hook.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'dehydrated/share')
-rwxr-xr-x | dehydrated/share/hooks/exit_hook.service-reload | 100 |
1 files changed, 73 insertions, 27 deletions
diff --git a/dehydrated/share/hooks/exit_hook.service-reload b/dehydrated/share/hooks/exit_hook.service-reload index cec5583..cf297ab 100755 --- a/dehydrated/share/hooks/exit_hook.service-reload +++ b/dehydrated/share/hooks/exit_hook.service-reload @@ -21,45 +21,91 @@ set -e -SERVICES="apache2 chrony haproxy knot postgresql redis-server" +Run_apache2 () +{ + if grep -Eqrs '^ *SSLCertificateFile' /etc/apache2/sites-enabled + then + service apache2 reload + fi +} -echo " + Reloading services..." +Run_chrony () +{ + if grep -Eqrs '^ *ntsservercert' /etc/chrony/chrony.conf /etc/chrony/conf.d/* + then + service chrony restart + fi +} -for SERVICE in ${SERVICES} -do - if service "${SERVICE}" status > /dev/null 2>&1 +Run_haproxy () +{ + if grep 'ssl crt' /etc/haproxy/haproxy.cfg | grep -qsv '^#' then - echo -n " + ${SERVICE}:" + service haproxy reload + fi +} - service "${SERVICE}" reload || service "${SERVICE}" restart +Run_knot_resolver () +{ + if grep -Eqrs '^ *net.tls' /etc/knot-resolver/* + then + INSTANCES="$(systemctl | grep -c 'kresd@*.service')" - echo " done." + if [ "${INSTANCES}" -gt 0 ] + then + for INSTANCE in $(seq 1 "${INSTANCES}") + do + service kresd@"${INSTANCE}" restart + done + fi fi -done +} -if grep -r -qs '^net.tls' /etc/knot-resolver/* && service kresd@1 status > /dev/null 2>&1 -then - NUMBER="$(systemctl | grep -c 'kresd@[0-9].service')" +Run_postfix () +{ + if grep -Eqrs '^ *smtpd_tls' /etc/postfix/main.cf + then + service postfix restart + fi +} - if [ "${NUMBER}" -gt 0 ] +Run_postgresql () +{ + if grep -Eqrs '^ *ssl_cert_file' /etc/postgresql/* then - echo -n " + knot-resolver:" + service postgresql reload + fi +} - for NUMBER in $(seq 1 "${NUMBER}") - do - echo -n " #${NUMBER}" - service kresd@"${NUMBER}" restart - done +Run_redis_sentinel () +{ + if grep -Eqrs '^ *tls-cert-file' /etc/redis/sentinel.conf + then + service redis-sentinel restart + fi +} - echo " done." +Run_redis_server () +{ + if grep -Eqrs '^ *tls-cert-file' /etc/redis/redis.conf + then + service redis-server restart fi -fi +} -if grep -r -qs '^smtpd_tls' /etc/postfix/main.cf/* && service postfix status > /dev/null 2>&1 -then - echo -n " + postfix:" +echo " + Reloading services:" + +SERVICES="apache2 chrony haproxy knot-resolver postfix postgresql redis-sentinel redis-server" + +for SERVICE in ${SERVICES} +do + if service "${SERVICE}" status > /dev/null 2>&1 + then + echo -n " + ${SERVICE}:" - service postfix restart + RELOAD="Run_$(echo "${SERVICE}" | sed -e 's|-|_|g')" + ${RELOAD} - echo " done." -fi + echo " done." + fi +done |