I had previously used the NetworkManager utility nm-online in my startup script as described in Waiting for networks, but now that I have moved to systemd-networkd that isn’t available anymore.
There is a fair amount of stuff on the net about the systemd service called systemd-networkd-wait-online.service. And indeed, that is a useful service, if one wants other services to wait for the network to be online. But somehow most of it seems to miss the point somehow, or at least one big point. I found various statements on the net that systemd doesn’t have the equivalent of nm-online. The only way in which that is true is if one means by it that systemd doesn’t have something as primitive. In truth what systemd has is much better, and much more powerful.
The key here is that the service, about which much is written, depends entirely on launching an executable called /lib/systemd/systemd-networkd-wait-online, about which almost nothing seems to be written.
That executable has much greater capability that nm-online, and the executable is available by itself. One can, within a script for example, launch the executable as:
/lib/systemd/systemd-networkd-wait-online -i wlan0:routable
For my purposes, within my startup script, being able to simply invoke this executable and wait until a particular adapter is up to the operational state of being able to route packets – that is exactly what I want.
A broader point which I think isn’t made sufficiently clear in what I have read is this. This is another case where the systemd complex does something right which is often done wrong. Rather than having systemd define what it means for the network to be “online”, they turn that definition over to the system administrator. By invoking this function with different parameters you get to ask it to wait for whatever you think “online” means.
I think this is a very well done piece of engineering.