I'm trying get netifd to trigger an ifup of an interface for me if it goes down. I'm using ModemManager, so specifically I'm looking for when the interface drops back from the state of "connected" to "registered".
Actually I'm stymied because I do not know where it is possible to put the logic for doing this, other than just writing a separate script or daemon in C. I see that in the x_proto.sh handlers there are functions for initialization and teardown. Are these files looped over at all? Is this where to add such functionality? Any tips appreciated.
The "hotplug" events are potentially useful here. There is a caveat that QMI and most of the ways of managing an LTE or similar modem need to poll the device for status changes in my experience; the modem doesn't "poke" the manager that it has lost connectivity.
I had considered hotplug scripts before but didn't know enough about how they worked. I am still unsure exactly what will trigger them, but I think it should work like this: all scripts in the /etc/hotplug.d/iface/ directory are executed in numerical order similar to how scripts in /etc/rc.d/ are, each script performs whatever actions it wants to, and the onus is on each script to not do anything too far beyond it's labelled scope.
It looks like you've already recognized that your script could cause events that could cause it to be executed again that could cause events ....
You might want to only take action on what is important to you. With the $ACTION, $INTERFACE, and $DEVICE variables, you should be able to only do what you need to when, for example, your wwan interface goes down. At least as I scanned your script, it takes action for up and down both, on every interface on your system.
Thanks for pointing that out. Overlooked that $INTERFACE in this context is already in use and I shouldn't have named my interface variable $INTERFACE.