From 92af4b365ba1dc348bf0def11cd4881fa60fc3be Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Wed, 20 Dec 2023 09:35:52 -0800 Subject: [PATCH] rework systemd stuff move service to paths.target remove startup dependency change to try-reload-or-restart which has this logic: Reload service if it supports it. If not, stop and then start instead. Does nothing if the service is not running. --- etc/letsencrypt/renewal-hooks/post/reload-services.sh | 7 ++----- systemd/letsencrypt-deploy.path | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/etc/letsencrypt/renewal-hooks/post/reload-services.sh b/etc/letsencrypt/renewal-hooks/post/reload-services.sh index b0b3fc9..dabd0d9 100644 --- a/etc/letsencrypt/renewal-hooks/post/reload-services.sh +++ b/etc/letsencrypt/renewal-hooks/post/reload-services.sh @@ -10,9 +10,6 @@ services=(apache2 dovecot exim4 haproxy postfix) # Cycle through each service. for service in "${services[@]}"; do - # Check if service is active. - if systemctl --quiet is-active $service; then - # Reload service. - systemctl reload $service - fi + # Reload service if it supports it. If not, stop and then start instead. This does nothing if the service is not running. + systemctl try-reload-or-restart $service done diff --git a/systemd/letsencrypt-deploy.path b/systemd/letsencrypt-deploy.path index 176c8d6..7253be0 100644 --- a/systemd/letsencrypt-deploy.path +++ b/systemd/letsencrypt-deploy.path @@ -1,6 +1,5 @@ [Unit] Description="Monitor /var/tmp/letsencrypt/ for cert names to deploy." -After=apache2.service [Path] # TriggerLimitIntervalSec=60 - not available until next version of systemd (250) @@ -10,4 +9,4 @@ DirectoryNotEmpty=/var/tmp/letsencrypt Unit=letsencrypt-deploy.service [Install] -WantedBy=multi-user.target +WantedBy=paths.target