2020-03-04 12:35:06 +03:00
#!/usr/bin/env bash
2021-10-17 19:13:06 +03:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2021-04-09 20:39:41 +03:00
set -eux
2019-08-10 17:03:07 +03:00
set -o pipefail
2023-05-08 23:38:34 +03:00
# Test ExecReload= (PR #13098)
2019-08-10 17:03:07 +03:00
systemd-analyze log-level debug
export SYSTEMD_PAGER =
SERVICE_PATH = " $( mktemp /etc/systemd/system/execreloadXXX.service) "
SERVICE_NAME = " ${ SERVICE_PATH ##*/ } "
echo "[#1] Failing ExecReload= should not kill the service"
2021-04-08 01:09:55 +03:00
cat >" $SERVICE_PATH " <<EOF
2019-08-10 17:03:07 +03:00
[ Service]
2024-01-04 17:24:52 +03:00
ExecStart = sleep infinity
2019-08-10 17:03:07 +03:00
ExecReload = /bin/false
EOF
systemctl daemon-reload
2021-04-09 20:49:32 +03:00
systemctl start " $SERVICE_NAME "
systemctl status " $SERVICE_NAME "
2019-08-10 17:03:07 +03:00
# The reload SHOULD fail but SHOULD NOT affect the service state
2023-04-05 16:50:42 +03:00
( ! systemctl reload " $SERVICE_NAME " )
2021-04-09 20:49:32 +03:00
systemctl status " $SERVICE_NAME "
systemctl stop " $SERVICE_NAME "
2019-08-10 17:03:07 +03:00
echo "[#2] Failing ExecReload= should not kill the service (multiple ExecReload=)"
2021-04-08 01:09:55 +03:00
cat >" $SERVICE_PATH " <<EOF
2019-08-10 17:03:07 +03:00
[ Service]
2024-01-04 17:24:52 +03:00
ExecStart = sleep infinity
2019-08-10 17:03:07 +03:00
ExecReload = /bin/true
ExecReload = /bin/false
ExecReload = /bin/true
EOF
systemctl daemon-reload
2021-04-09 20:49:32 +03:00
systemctl start " $SERVICE_NAME "
systemctl status " $SERVICE_NAME "
2019-08-10 17:03:07 +03:00
# The reload SHOULD fail but SHOULD NOT affect the service state
2023-04-05 16:50:42 +03:00
( ! systemctl reload " $SERVICE_NAME " )
2021-04-09 20:49:32 +03:00
systemctl status " $SERVICE_NAME "
systemctl stop " $SERVICE_NAME "
2019-08-10 17:03:07 +03:00
echo "[#3] Failing ExecReload=- should not affect reload's exit code"
2021-04-08 01:09:55 +03:00
cat >" $SERVICE_PATH " <<EOF
2019-08-10 17:03:07 +03:00
[ Service]
2024-01-04 17:24:52 +03:00
ExecStart = sleep infinity
2019-08-10 17:03:07 +03:00
ExecReload = -/bin/false
EOF
systemctl daemon-reload
2021-04-09 20:49:32 +03:00
systemctl start " $SERVICE_NAME "
systemctl status " $SERVICE_NAME "
systemctl reload " $SERVICE_NAME "
systemctl status " $SERVICE_NAME "
systemctl stop " $SERVICE_NAME "
2019-08-10 17:03:07 +03:00
systemd-analyze log-level info