Cyril Brulebois <[email protected]> (2023-01-22): > The configuration found below manages to: > - let my allow-hotplug slow-to-appear wireless interface come up at > boot-up, via the udev integration; > - allow me to stop and start networking, losing then regaining all > relevant configs (main connection is wireless, with WPA, with DHCP, > and SLAAC via RAs, without /e/n/i conf for SLAAC, see #1029352); > - allow me to restart networking, [same as previous entry]. > > This is just an example of something that seems to be working fine > enough during my very limited testing, there might be cleaner ways to do > this, better names to choose (I picked a neutral “environment” but my > first thought was an explicit “maybe-redo-hotplug”), etc.: > > [Service] > Type=oneshot > EnvironmentFile=-/etc/default/networking > EnvironmentFile=-/run/network/environment > ExecStart=/sbin/ifup -a --read-environment $ALLOW_HOTPLUG > ExecStop=/sbin/ifdown -a --read-environment --exclude=lo > ExecStopPost=/bin/sh -c "echo ALLOW_HOTPLUG=--allow=hotplug > > /run/network/environment" > RemainAfterExit=true > TimeoutStartSec=5min > > Changes (compared to the original ifupdown service unit): > - an extra /run/network/environment is read if present, no errors > otherwise; of course it doesn't exist during boot-up, since > /run is brand new and nothing else is creating it; > - ExecStopPost populates that file with ALLOW_HOTPLUG=--allow=hotplug > after each “stop” (possibly part of a “restart”) is done; > - ExecStart gets an extra $ALLOW_HOTPLUG parameter, that's either > an empty string (at boot-up) or --allow=hotplug (after boot-up).
Of course I'm not familiar with the ifup interface so I fudged it. Now,
with an extra ens3 declared as auto, the following seems to work fine
for boot-up, stop and start, and restart:
[Service]
Type=oneshot
EnvironmentFile=-/etc/default/networking
ExecStart=/sbin/ifup -a --read-environment
ExecStart=/bin/sh -c 'if [ -f /run/network/restart-hotplug ]; then
/sbin/ifup -a --read-environment --allow=hotplug; fi'
ExecStop=/sbin/ifdown -a --read-environment --exclude=lo
ExecStopPost=/usr/bin/touch /run/network/restart-hotplug
RemainAfterExit=true
TimeoutStartSec=5min
I have no opinions on how to best handle possible errors regarding the
hotplug interfaces; but again, that's secondary compared to fixing the
“start” use case.
Cheers,
--
Cyril Brulebois ([email protected]) <https://debamax.com/>
D-I release manager -- Release team member -- Freelance Consultant
signature.asc
Description: PGP signature

