Oleg A. Arkhangelsky wrote:
Note that we have to use '--ignore-errors'. Otherwise if we have real
hotplug interface that is not present at the moment of restart, `ifup`
returns non-zero and systemd unit fail.
"--ignore-errors" marks missing interfaces as configured, so ifup will
not configure them when invoked by udev. In order to not fail the
systemd unit start on ifup error, you can prefix the command with "-".
On 22/01/2023 at 20:58, Cyril Brulebois wrote:
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
That seems needlessly convoluted. What about this:
[Service]
Type=oneshot
EnvironmentFile=-/etc/default/networking
ExecStart=/sbin/ifup -a --read-environment
ExecStart=-/sbin/ifup -a --read-environment --allow=hotplug
ExecStop=/sbin/ifdown -a --read-environment --exclude=lo
RemainAfterExit=true
TimeoutStartSec=5min
"start" and "restart" configure all existing "auto" and "allow-hotplug"
interfaces.
Missing "allow-hotplug" interfaces do not be marked as configured (so
that they can be configured by udev) and do not make "start" or
"restart" fail.