On Thu, 2015-01-22 at 19:51 +0300, Andrei Borzenkov wrote: > В Thu, 22 Jan 2015 16:44:52 +0100 > Igor Bukanov <i...@mir2.org> пишет: > > > For a service that should be shutdown when network is not available, I > > tried to use Requires=network-online.target . However, on Fedora 21 > > with NetworkManager that does not work. When I switch off WiFi, the > > only connection on my laptop that can configure default IP route and > > setup /etc/resolv.conf, network-online.target still stays active and > > my service continues to run. Is it a bug in Fedora? If not, what is a > > canonical way to implement such dependency? > > > No, it is not a bug. network-online was never intended to be used this > way. It was intended to be used only during startup; when initial > startup is finished, state of this service is largely irrelevant. > > network-online.target itself does absolutely nothing. It is provided as > well known name for other services to order itself after; and you need > to provide implementation that orders itself before. > > For NM implementation would be NetworkManager-wait-online.service that > basically does nothing more than calling nm-online. > > Note that "network down" does not cause any change state in systemd. > NetworkManager still runs. systemd itself does not watch or manages > network, so it cannot initiate any actions here. I suppose you really > want to hook systemctl stop/systemctl start in NetworkManager > dispatcher framework.
Yeah, a dispatcher script ("man NetworkManager" has more info) will be executed whenever any network interface is deconfigured by NetworkManager. You could use this, in combination with 'nmcli -f STATE -t g' (which reports the NM state as a single word, eg "connected" or "disconnected" or "connecting"), to determine when no network connections are active, and then run 'systemctl stop your-service". See also http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/dispatcher Dan _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel