Hello,
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?
(sorry for poor English, I'm russian)
[Request] Wifi settings change on boot
Re: [Request] Wifi settings change on boot
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 runAnt wrote:Hello,
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?
(sorry for poor English, I'm russian)
Code: Select all
dietpi-config 8 1

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.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Re: [Request] Wifi settings change on boot
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?
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?
Re: [Request] Wifi settings change on boot
You can also change the dietpi.txt in the root of the SDCard. It has WiFi settings there.
Re: [Request] Wifi settings change on boot
There is a few ways to do what you need:Ant wrote: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?
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).
If you want to do this as as service, on wheezy, here is an example service: https://github.com/Fourdee/DietPi/blob/ ... pi-service. You would be best to run your script before $network. This way you can just modify the /etc/network/interfaces file
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
Code: Select all
cat << _EOF_ > /etc/systemd/system/dietpi-service.service
[Unit]
Description=DietPi Bootup and Shutdown Service
Before=network-pre.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/DietPi/dietpi/conf/dietpi-service start
ExecStop=/DietPi/dietpi/conf/dietpi-service stop
StandardOutput=tty
[Install]
WantedBy=multi-user.target
_EOF_
systemctl enable dietpi-service
systemctl daemon-reload
https://github.com/Fourdee/DietPi/blob/ ... up#L41-L53. You would be best waiting for a UUID rather than /dev/sda
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Re: [Request] Wifi settings change on boot
Correct.Ant wrote:Dietpi.txt works on first boot, as I know
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Donating is the easiest – you can use PayPal or become a DietPi patron.