From 5806882f85ab80d8cf284ce3d41c1f2f298015b6 Mon Sep 17 00:00:00 2001 From: lrnselfreliance <33263708+lrnselfreliance@users.noreply.github.com> Date: Mon, 30 Nov 2026 15:06:21 -0700 Subject: [PATCH] Repair: restart a running tunnel and torrents, so an upgrade loads their new code (#1040) repair.sh ends with systemctl start wrolpi.target, which leaves a running unit as it was. wrolpi-vpn (the root tunnel) and wrolpi-torrent kept the old code until a reboot, so a tunnel.py fix did not apply after an upgrade. try-restart restarts them only if they are running. Co-authored-by: Claude Opus 5.5 --- controller/test/test_vpn_tunnel.py | 9 +++++++++ repair.sh | 3 +++ 2 files changed, 12 insertions(+) diff --git a/controller/test/test_vpn_tunnel.py b/controller/test/test_vpn_tunnel.py index 7c29947f..188e4b44 100644 --- a/controller/test/test_vpn_tunnel.py +++ b/controller/test/test_vpn_tunnel.py @@ -674,6 +674,15 @@ class TestInstalled: 'etc/raspberrypios/wrolpi.target'): assert 'wrolpi-vpn.service' in (REPOSITORY / script).read_text(), script + def test_repair_restarts_a_running_tunnel(self): + """An upgrade (which ends with repair.sh) must load a new tunnel.py: `systemctl start wrolpi.target` leaves a + running tunnel on the old code. Torrents are restarted with it (they run in its namespace, behind its kill + switch). try-restart: neither is started if it was not running.""" + repair = (REPOSITORY / 'repair.sh').read_text() + restart = 'systemctl try-restart wrolpi-vpn.service wrolpi-torrent.service' + assert restart in repair + assert repair.index(restart) < repair.index('systemctl start wrolpi.target') + def test_packages(self): for packages in ('pi-gen/stage2/04-wrolpi/01-packages-nr', 'debian-live-config/config/package-lists/wrolpi.list.chroot'): diff --git a/repair.sh b/repair.sh index 41dec435..3da3f490 100755 --- a/repair.sh +++ b/repair.sh @@ -219,6 +219,9 @@ fi systemctl restart wrolpi-help # Restarted, not only started: its config may have changed. systemctl restart wrolpi-rsyncd || : +# A running tunnel (and torrents, in its namespace) must load the new code; starting wrolpi.target leaves it as it +# was. Only if running: a stopped VPN stays stopped. +systemctl try-restart wrolpi-vpn.service wrolpi-torrent.service || : systemctl start wrolpi.target set +x