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