Is it possible to use dietpi-config not “interactively”? I need to setup Wi-Fi from python/shell script, I am trying to recreate action from “Save all changes and restart networking” in dietpi-config, but it’s not working as expected. I would like to trigger this action manually from within python/shell script, is this possible?
Not that I am aware of, but there is the firstboot service which applies the settings from dietpi.txt.
So you fill in the disired config in dietpi.txt and recrate also dietpi-wifi.txt (it gets removed after first boot) and probably also need to delete /var/lib/dietpi/dietpi-wifi.db and retrigger this service, but Idk what side effects this could have.
After this sequence I can see wlan0 in ifconfig, but ip link shows state DORMANT and there is no internet connection. When I go to dietpi-config and restart networking from there, it works
Ok, I think there is a misunderstanding here. diepti-wifi.db stores information about scanned WiFi networks (scanned with dietpi-config).
When you run /boot/dietpi/func/dietpi-wifi you can chose one of this configs, which is then applied to the wpa_supplicant.conf. And with this config file the network stack knowns where to connect to, so you just have some credentials in the db, but they are never applied.
If you just want to connect to one wifi network, edit the wpa_supplicant.conf directly.
I assume you have setup the wifi interface already, so you don’t need to change anything inside /etc/network/interfaces.
The modprobe would be also unecessary.
If you just want to change wifi credentials (and the interface is already set up), just edit wpa_supplicant.conf and you don’t even need to restart the interface, you can just do