I've been able to fix the issue using the following configuration:
[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"
I found the solution via this comment on an Ubuntu-bugreport, which refers to a similar problem with shorewall instead of usb_modeswitch.
DefaultDependencies is defined as:
will implicitly complement all configured dependencies of type Wants= or Requires= with dependencies of type After=
I have not tested if this setting is a key part of the configuration or if it can be left out.
--
Here's the full explanation from the aforementioned bug-report (For shorewall instead of 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.
Whatever the exact cause was, this configuration works for me and doesn't seem to have any undesired effects.