I am trying to force a script wait for network readiness, following the suggestions @DBMandrake provided here:
My first attempt uses the (simpler looking) approach to make the whole rc.local launch wait for network. Unfortunately, it did not work. Here is what I did:
created a directory rc.local.service.d, and confirmed it has the same permissions as all the other directories here (rwxr-xr-x root root).
created a local.conf file inside the new directory. The permissions here seem to match those on local.conf in other directories, like bluetooth.service.d (rw-r–r-- root root), so I think this is OK.
in local.conf, I added only the lines specified:
commented out the sleep 10 delay I had previously inserted into rc.local as a first workaround.
rebooted
the network problems came back
Error while loading service
Unable to find the server at api.twilio.com
I do not know how to confirm for certain, but it seems to me that rc.local did not wait for the network to be ready? The reasons I think this are:
if I manually run rc.local at this point (sudo /etc/rc.local), it starts correctly. I assume this is because by now the network is up.
if I add back sleep 10 to rc.local, everythink works correctly again on reboot.
Am I doing something wrong with the network-online.target approach?
As far as I know, yes. I believe I have always used OSMC with that option enabled, but admittedly I was working from CLI and did not explicitly check. Is there a way to check using SSH? Otherwise I will double-check in GUI later.
@DBMandrake I spent some time today reading the documentation on systemd. I think that to be consistent with the corresponding service, the filename needs to be rc-local.service.d instead of rc.local.service.d (i.e. dash instead of dot).
Once I made the change, I was able to remove the artificial sleep statement in rc.local and my process still worked fine - presumably waiting for network before proceeding.
I can also see that rc-local.service correctly recognizes the new dependencies: