I am looking for an elegant way to implement fallback behavior for the onboard Wifi. I want the raspberry pi to set up its own ad-hoc AP when it is not able to connect to an existing network.
For now, I intend to have it make this decision on boot (so that if i lose a connection to a network and I want it to start up in ad hoc mode I would reboot), so in my rc.local I determine if hostname -I
produces anything, if not I want to configure ad hoc mode.
here is an example of instructions for doing just that, but I am hoping to find out if there is a way that I can do it without changing the file and saving it, because if I change the system configuration then it will stay as that upon reboot. I want it to revert back to original wpa_supplicant behavior upon reboot always and only set wlan0 up as ad-hoc when wpa_supplicant cannot connect to a network during boot.
So far the only thing I can think of is to change /etc/network/interfaces
to ad-hoc config, restart networking, and then change /etc/network/interfaces
back. This way there is only a small race condition during which a reboot would have the system stuck in ad-hoc mode during boot.