From ce8f6c4c6bb8a8469ac90dc6a154beef4a1acdf3 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 1 Feb 2023 18:48:38 +0100 Subject: [PATCH] ubuntu 18: systemd kill ends up killing the script itself This is because KillMode=control-group by default (cherry picked from commit c07c8b5bb8feb055bd1770783d07bbeadff9281f) --- src/scripts/restartservice.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/scripts/restartservice.sh b/src/scripts/restartservice.sh index 274a453fc..4f09f7805 100755 --- a/src/scripts/restartservice.sh +++ b/src/scripts/restartservice.sh @@ -35,9 +35,13 @@ elif [[ "${service}" == "docker" ]]; then elif [[ "${service}" == "collectd" ]]; then systemctl restart --no-block collectd elif [[ "${service}" == "box" ]]; then - # ExecReload does not work on ubuntu 18 - # systemctl reload --no-block box - systemctl kill --signal=SIGHUP box + readonly ubuntu_version=$(lsb_release -rs) + if [[ "${ubuntu_version}" == "18.04" ]]; then + pid=$(systemctl show box -p MainPID | sed 's/MainPID=//g') + kill -HUP $MAINPID + else + systemctl reload --no-block box + fi else echo "Unknown service ${service}" exit 1