]>
Commit | Line | Data |
---|---|---|
ff12a795 | 1 | #!/usr/bin/env bash |
7b3cec95 | 2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
084575ff | 3 | set -eux |
38d8a123 FS |
4 | set -o pipefail |
5 | ||
539af5c4 FS |
6 | # Test ExecReload= (PR #13098) |
7 | ||
38d8a123 | 8 | systemd-analyze log-level debug |
38d8a123 FS |
9 | |
10 | export SYSTEMD_PAGER= | |
11 | SERVICE_PATH="$(mktemp /etc/systemd/system/execreloadXXX.service)" | |
12 | SERVICE_NAME="${SERVICE_PATH##*/}" | |
13 | ||
14 | echo "[#1] Failing ExecReload= should not kill the service" | |
0ee99483 | 15 | cat >"$SERVICE_PATH" <<EOF |
38d8a123 | 16 | [Service] |
63403f07 | 17 | ExecStart=sleep infinity |
38d8a123 FS |
18 | ExecReload=/bin/false |
19 | EOF | |
20 | ||
21 | systemctl daemon-reload | |
38825267 FS |
22 | systemctl start "$SERVICE_NAME" |
23 | systemctl status "$SERVICE_NAME" | |
38d8a123 | 24 | # The reload SHOULD fail but SHOULD NOT affect the service state |
128db0aa | 25 | (! systemctl reload "$SERVICE_NAME") |
38825267 FS |
26 | systemctl status "$SERVICE_NAME" |
27 | systemctl stop "$SERVICE_NAME" | |
38d8a123 FS |
28 | |
29 | ||
30 | echo "[#2] Failing ExecReload= should not kill the service (multiple ExecReload=)" | |
0ee99483 | 31 | cat >"$SERVICE_PATH" <<EOF |
38d8a123 | 32 | [Service] |
63403f07 | 33 | ExecStart=sleep infinity |
38d8a123 FS |
34 | ExecReload=/bin/true |
35 | ExecReload=/bin/false | |
36 | ExecReload=/bin/true | |
37 | EOF | |
38 | ||
39 | systemctl daemon-reload | |
38825267 FS |
40 | systemctl start "$SERVICE_NAME" |
41 | systemctl status "$SERVICE_NAME" | |
38d8a123 | 42 | # The reload SHOULD fail but SHOULD NOT affect the service state |
128db0aa | 43 | (! systemctl reload "$SERVICE_NAME") |
38825267 FS |
44 | systemctl status "$SERVICE_NAME" |
45 | systemctl stop "$SERVICE_NAME" | |
38d8a123 FS |
46 | |
47 | echo "[#3] Failing ExecReload=- should not affect reload's exit code" | |
0ee99483 | 48 | cat >"$SERVICE_PATH" <<EOF |
38d8a123 | 49 | [Service] |
63403f07 | 50 | ExecStart=sleep infinity |
38d8a123 FS |
51 | ExecReload=-/bin/false |
52 | EOF | |
53 | ||
54 | systemctl daemon-reload | |
38825267 FS |
55 | systemctl start "$SERVICE_NAME" |
56 | systemctl status "$SERVICE_NAME" | |
57 | systemctl reload "$SERVICE_NAME" | |
58 | systemctl status "$SERVICE_NAME" | |
59 | systemctl stop "$SERVICE_NAME" | |
38d8a123 FS |
60 | |
61 | systemd-analyze log-level info |