Diet Pi Wifi Setup

Hello,

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?

Thanks,

Patryk

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 :thinking: and retrigger this service, but Idk what side effects this could have.

See:
https://dietpi.com/docs/usage/#network-configuration
https://github.com/search?q=repo:MichaIng/DietPi%20dietpi-wifi.txt&type=code

1 Like

you can do all activities manually, same way as you would do without DietPi tooling on every Linux system. There is no need to use our tools.

What exactly do you wanna achieve? Setup wifi (and drivers etc) on variety of different machines or what exactly is your goal?

My exact goal:

  1. Add/modify Wi-Fi instance in dietpi-wifi.db
  2. Restart networking with applied update.

I am updating dietpi-wifi.db with python and then I’ve followed commands that I’ve seen in the console output from dietpi-config:

  • mkdir -p /etc/wpa_supplicant
  • chown root:root /var/lib/dietpi/dietpi-wifi.db /etc/wpa_supplicant/wpa_supplicant.conf
  • chmod 600 /var/lib/dietpi/diet-wifi.db /etc/wpa_supplicant/wpa_supplicant.conf
  • modprobe cfg80211
  • systemctl daemon-reload
  • systemctl restart ifup@wlan0

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

sudo wpa_cli -i wlan0 reconfigure

and check service log for ifup@wlan0 so check what happend

It shows DORMANT probably because there is no valid config in wpa_supplicant.conf