I am trying to run an executable, right before shutdown, that needs NetworkManager running. Here is the service file that I currently have (located in /lib/systemd/system), and it works fine if I have an ethernet connection, but does not work if I only have a wireless connection:
[Unit] Requires=network.target Requires=NetworkManager.service Before=shutdown.target After=network.target NetworkManager.service [Service] Type=oneshot RemainAfterExit=true ExecStart=/bin/true ExecStop=MyShutdownExecutable [Install] wantedBy=multi-user.target
This is running on an embedded device, and sometimes the user will have an ethernet connection, sometimes only a wireless connection, sometimes both - so this needs to work with all these combinations of network connectivity.
At one point in my testing, during shutdown I saw a message that NetworkManager had shutdown before my executable had run. I was under the impression that having After=NetworkManager.service in my service file should guarantee that NetworkManager should not shutdown until after my executable finishes - which seems to be the case when I have an ethernet connection.
Any help would be appreciated greatly.