Enable/disable Wi-fi hotspot programmatically on pi zero?

Is it possible to interface with dietpi-config programmatically? So that I can enable and then disable the wifi hotspot? (it seems this requires ethernet, but the pi zero doesn’t have ethernet, so how do you use hotspot on dietpi with pi zero?)

If not through dietpi-config, is there another way?

I suppose I could write a bash script to handle it, but curious if there’s an easier way before I spend hours building a custom solution.

Looks like I may be able to use this, which I just confirmed works.

https://github.com/lukicdarkoo/rpi-wifi

Remove line 191 from the configure file.

Then I can modify /bin/rpi-wifi.sh to take in ‘up’ or ‘down’ to start and stop the AP when needed.

I’m not great at Linux, still a lot to learn.

I did some digging around the dietpi funcs and realized it was overwriting some of the config from the rpi-wifi I ran, so I did some light editing to dietpi-config and seems to work great.

Now I can just ifdown the ap0 interface and ifup when I’m ready to use it.

Hi,

many thanks for sharing your problem as well as solution. As you already find out, DietPi is not supporting simultaneous AP and Managed Mode Wifi on one interface. But rpi-wifi tool seems to close the gap. But yeah dietpi-config will clean your /etc/network/interfaces if used, because it’s not expecting something like ap0. Maybe youlike to share the changes you have done on dietpi-config to overcome this situation.

dietpi-config btw does not override /etc/network/interfaces, but it might not detect or being able to apply changes to this file correctly anymore as it depends on a fixed content… Rework is in pipeline to allow a flexible per-interface configuration.

What is already possible now is to apply custom changes via new files in /etc/network/interfaces.d/your_conf to have them independent from any changes to the main files. With the rework, the new dietpi-network will use drop-on per-interface configs itself and will allow configuration via command line options as well.