mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
As 'systemctl stop' is called with --no-block, previously systemd-resolved
might not be stopped when 'resolvectl' is called, and the DBus connection
might be closed during the call:
```
TEST-07-PID1.sh[5643]: + systemctl stop --no-block systemd-resolved.service
TEST-07-PID1.sh[5643]: + resolvectl
TEST-07-PID1.sh[5732]: Failed to get global data: Remote peer disconnected
```
Follow-up for 8eefd0f4de.
Fixes https://github.com/systemd/systemd/pull/39388#issuecomment-3439277442.
47 lines
1.2 KiB
Bash
Executable File
47 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
set -eux
|
|
set -o pipefail
|
|
|
|
# For issue #39247.
|
|
|
|
at_exit() {
|
|
set +e
|
|
|
|
rm -rf /run/systemd/system/systemd-resolved.service.d/
|
|
systemctl daemon-reload
|
|
systemctl restart systemd-resolved.service
|
|
}
|
|
|
|
trap at_exit EXIT
|
|
|
|
mkdir -p /run/systemd/system/systemd-resolved.service.d/
|
|
cat >/run/systemd/system/systemd-resolved.service.d/99-start-limit.conf <<EOF
|
|
[Unit]
|
|
StartLimitBurst=5
|
|
StartLimitInterval=100
|
|
|
|
[Service]
|
|
ExecStopPost=sleep 10
|
|
EOF
|
|
|
|
systemctl daemon-reload
|
|
systemctl restart systemd-resolved.service
|
|
systemctl reset-failed systemd-resolved.service
|
|
systemctl status --no-pager systemd-resolved.service
|
|
systemctl show systemd-resolved.service | grep StartLimit
|
|
|
|
for i in {1..5}; do
|
|
echo "Start #$i"
|
|
|
|
systemctl stop --no-block systemd-resolved.service
|
|
# Wait for systemd-resolved in ExecStart= being stopped.
|
|
# shellcheck disable=SC2016
|
|
timeout 10 bash -c 'until [[ "$(systemctl show --property=MainPID --value systemd-resolved.service)" == 0 ]]; do sleep 0.1; done'
|
|
if ! resolvectl; then
|
|
journalctl -o short-monotonic --no-hostname --no-pager -u systemd-resolved.service -n 15
|
|
exit 1
|
|
fi
|
|
systemctl is-active systemd-resolved.service
|
|
done
|