DietPi icon indicating copy to clipboard operation
DietPi copied to clipboard

Network | Poll dietpi-wifi.txt on each boot

Open mdr92 opened this issue 1 year ago • 4 comments

Sometimes I take my Pi to a new location, to connect to wifi at the new location I need to get an ethernet connection or a monitor/tv with keyboard/mouse which is quite a hassle.

Any chance for it to check dietpi-wifi.txt or similar on each boot? That would mean I can could just put the micro sd card in a reader and edit the text file on my phone/laptop with the wifi details for the new location, put the card back in and boot with the network connection.

It would make it much easier to move Pi's around, Thanks

mdr92 avatar Jun 15 '23 23:06 mdr92

Couldn't this be done by editing/modifying the wpa_supplicant.conf?

JappeHallunken avatar Jun 16 '23 09:06 JappeHallunken

Isn't that stored on the Linux partitions so not really editable from Windows/Android and an sd card reader.

mdr92 avatar Jun 16 '23 12:06 mdr92

I think it would be best to remove the file by default, since it may contain sensitive information on a world-readable and easy accessible storage device.

Probably we can do it like that:

  • Add an additional variable to dietpi-wifi.txt, which indicates whether to leave that file in place or not.
  • Run /boot/dietpi/func/dietpi-wifidb 1 as part of dietpi-preboot if /boot/dietpi-wifi.txt exists.

To not make it too complicated, it would run regardless whether WiFi has been actually enabled or not and it means that /etc/wpa_supplicant/wpa_supplicant,conf is rewritten on every boot.

On very first boot, /boot/dietpi/func/dietpi-wifidb 1 currently runs in the dedicated dietpi-firstboot script. But I see no reason why this couldn't run in preboot, which run first. dietpi-wifidb does nothing more than translating dietpi-wifi.txt into wpa_supplicant,conf, so is pretty independent of any other setup steps.

MichaIng avatar Jun 26 '23 19:06 MichaIng

Hello Michal,

I've found that if I remove the micro SD card and insert it into a card reader, then edit the file located at /boot/dietpi/preboot by adding the line /boot/dietpi/func/dietpi-wifidb 1, and also create a file named dietpi-wifi.txt in the boot directory with my updated Wi-Fi credentials:

aWIFI_SSID[0]='YourSSID' aWIFI_KEY[0]='YourPassword'

This method consistently works for me. It appears that this feature may already exist?

LiminalD avatar Feb 21 '24 06:02 LiminalD