Consegui corrigir o problema usando a seguinte configuração:
[Unit]
Description=USB_ModeSwitch
DefaultDependencies=no
After=local-fs.target systemd-sysctl.service
Before=network-pre.target shutdown.target
Wants=network-pre.target
Conflicts=shutdown.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/usb_modeswitch_dispatcher --switch-systemd %I
Environment="TMPDIR=/run"
Eu encontrei a solução via este comentário em um Ubuntu- bugreport, que se refere a um problema similar com shorewall em vez de usb_modeswitch.
DefaultDependencies é definido como :
will implicitly complement all configured dependencies of type Wants= or Requires= with dependencies of type After=
Eu não testei se essa configuração é uma parte importante da configuração ou se ela pode ser deixada de fora.
-
Aqui está a explicação completa do relatório de bugs mencionado acima (para shorewall em vez de usb_modeswitch):
Shorewall does not come with a systemd native service unit description. Such description is being generated at boot by /lib/systemd/system-generators/systemd-sysv-generator based on /etc/init.d/shorewall. I have noticed, however, that the LSB header of /etc/init.d/shorewall wants the service to be started from /etc/rcS.d, which is pretty early, and at the same time it has Required-Start: $network $remote_fs, which is a pretty strong requirement. In fact, this is the only script in /etc/rcS.d that requires $network (well, except shorewall6, which exhibits exactly the same problem). Looking into the auto-generated unit in /run/systemd/generator.late/shorewall.service shows:
DefaultDependencies=no
Before=sysinit.target shutdown.target
After=network-online.target remote-fs.target
Wants=network-online.target
Conflicts=shutdown.target
This looks problematic: sysinit.target is a very early target, most higher level services are started after it, and on many systems (including mine) various dependencies will make network-online.target available only after sysinit.target.
Qualquer que seja a causa exata, esta configuração funciona para mim e não parece ter nenhum efeito indesejado.