2020-03-04 09:35:06 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-08-10 14:03:07 +00:00
|
|
|
|
2021-04-09 17:39:41 +00:00
|
|
|
set -eux
|
2019-08-10 14:03:07 +00:00
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
systemd-analyze log-level debug
|
|
|
|
systemd-analyze log-target console
|
|
|
|
|
|
|
|
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-07 22:09:55 +00:00
|
|
|
cat >"$SERVICE_PATH" <<EOF
|
2019-08-10 14:03:07 +00:00
|
|
|
[Service]
|
|
|
|
ExecStart=/bin/sleep infinity
|
|
|
|
ExecReload=/bin/false
|
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
2021-04-09 17:49:32 +00:00
|
|
|
systemctl start "$SERVICE_NAME"
|
|
|
|
systemctl status "$SERVICE_NAME"
|
2019-08-10 14:03:07 +00:00
|
|
|
# The reload SHOULD fail but SHOULD NOT affect the service state
|
2021-04-09 17:49:32 +00:00
|
|
|
systemctl reload "$SERVICE_NAME" && { echo 'unexpected success'; exit 1; }
|
|
|
|
systemctl status "$SERVICE_NAME"
|
|
|
|
systemctl stop "$SERVICE_NAME"
|
2019-08-10 14:03:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
echo "[#2] Failing ExecReload= should not kill the service (multiple ExecReload=)"
|
2021-04-07 22:09:55 +00:00
|
|
|
cat >"$SERVICE_PATH" <<EOF
|
2019-08-10 14:03:07 +00:00
|
|
|
[Service]
|
|
|
|
ExecStart=/bin/sleep infinity
|
|
|
|
ExecReload=/bin/true
|
|
|
|
ExecReload=/bin/false
|
|
|
|
ExecReload=/bin/true
|
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
2021-04-09 17:49:32 +00:00
|
|
|
systemctl start "$SERVICE_NAME"
|
|
|
|
systemctl status "$SERVICE_NAME"
|
2019-08-10 14:03:07 +00:00
|
|
|
# The reload SHOULD fail but SHOULD NOT affect the service state
|
2021-04-09 17:49:32 +00:00
|
|
|
systemctl reload "$SERVICE_NAME" && { echo 'unexpected success'; exit 1; }
|
|
|
|
systemctl status "$SERVICE_NAME"
|
|
|
|
systemctl stop "$SERVICE_NAME"
|
2019-08-10 14:03:07 +00:00
|
|
|
|
|
|
|
echo "[#3] Failing ExecReload=- should not affect reload's exit code"
|
2021-04-07 22:09:55 +00:00
|
|
|
cat >"$SERVICE_PATH" <<EOF
|
2019-08-10 14:03:07 +00:00
|
|
|
[Service]
|
|
|
|
ExecStart=/bin/sleep infinity
|
|
|
|
ExecReload=-/bin/false
|
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
2021-04-09 17:49:32 +00:00
|
|
|
systemctl start "$SERVICE_NAME"
|
|
|
|
systemctl status "$SERVICE_NAME"
|
|
|
|
systemctl reload "$SERVICE_NAME"
|
|
|
|
systemctl status "$SERVICE_NAME"
|
|
|
|
systemctl stop "$SERVICE_NAME"
|
2019-08-10 14:03:07 +00:00
|
|
|
|
|
|
|
systemd-analyze log-level info
|
|
|
|
|
2021-04-07 22:09:55 +00:00
|
|
|
echo OK >/testok
|
2019-08-10 14:03:07 +00:00
|
|
|
|
|
|
|
exit 0
|