2017-06-17 23:47:50 UTC
I didn't found anything about the following problem:
There is network.target and network-online.target. In combination with
NetworkManager network-online.target get started, when
NetworkManager-wait-online.service exits successfull.
This is all ok, if i have a computer with permanent LAN/WLAN-connection.
But it doesn't fit the needs for laptops moved in different networks.
I need NetworkManager, because i use LAN, WLAN, Modem-Connections as
well as USB-Thetering. So a setup with networkd is not the best way in
I have some ftp-mountpoints, which i have configured with automount and
auto-unmounting after idle-time.
When the automount is activated on boot, a simple ls on this mountpoint
can block the whole system, when there is no network. So i bound the
automount-unit to network-online.target with
"BindsTo=network-online.target". This works fine. ls gives me an empty
directory, when no network-connection is active, and gives me back the
content of the mounted dir, when the network-connection is active.
When i stop the network-connection from the gnome-nm-applet, or when i'm
sitting in a train and there is no network-connection possible (in case
of a tunnel), the automount-unit should be stopped. But in normal
configuration this never will happen.
Do you have any suggestions, how to solve this problem?
I tried a solution:
i created a simple script, which checks the connection every minute. Is
there a connection, and is this connection working (realized with a ping
to a server in the internet), then network-online.target gets (re)started.
If there is no connection, or the connection is not working (think about
WLAN in a train in a tunnel, WLAN is working, but no connection to the
internet is possible), network-online.target gets stopped.
Also a simple script in NetworkManager/dispatcher.d/, wich starts
network-online.target, when a connection changes its state zu up, and
stop this target, when a connection changes to down.
All services, which should stop on closing the network-connection have
the dependency BindsTo=network-online.target
But i'm not sure, if this is a good solution to change the behaviour of
network-online.target. Should i create a own target? Or is there
another, better solution?