How can I change WiFi settings on a system running without monitor,keyboard, etc?
For example, WiFi radio made from RPi+DietPi worked fine in my house, then I give it to my friend (another wifi network). But he is not familiar with Linux and SSH, all he need is radio working with his Wifi spot.
Maybe he will give radio to someone else later, and I can not change ssid settings every time for every user.
So how can I program simple replace of /etc/network/interfaces file on boot, or there is another way exists?
Although you mentioned the system will be headless. For the sake of simplicity, when your friend runs the Pi for the 1st time, just plug a keyboard + Monitor in, then run
dietpi-config 8 1
Select Wifi, then scan and connect, exit, job done
If you want to automate the modifications to your /etc/network/interfaces file on boot, you would need to create a script during boot phase that reads a file/settings from /boot (fat partition on sd), then modifies the /etc/network/interfaces file before network is loaded.
RPi is inside of radio case, with many soldered wires, and it’s impossible to attach monitor to it.
I’m talking about automation. Where can I write command to execute bash script (python will be better) on system boot? I read about udev rules, created one (created additional file), but it does not works. Whether there are other ways to run my script? - I want to detect plugged usb stick, read file from it, and copy that file to /etc/network/
So, first run will be with wrong wifi settings, than I’m insert usb stick, replace interfaces file, and second start gonna be ok. Is it correct way?
There is a few ways to do what you need:
The easiest would be to add your script to /etc/rc.local. As this runs last, you would need to code a system that disconnects the wifi, changes /etc/network/interfaces and reconnects wifi (eg: ifdown wlan0 & ifup wlan0).
Jessie, you can use systemd. Here is an example service:
You would be best to run your script before network, i believe its network-pre.target. This way you can just modify the /etc/network/interfaces file. You can simply use ExecStart=/My/Script.sh