ubuntu 18: systemd kill ends up killing the script itself

This is because KillMode=control-group by default

(cherry picked from commit c07c8b5bb8)
This commit is contained in:
Girish Ramakrishnan
2023-02-01 18:48:38 +01:00
parent 0832ebf052
commit ce8f6c4c6b

View File

@@ -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