Image as AP only or STA only

When you go through the wizard to setup as AP or client, what things are saved to tell openwrt whether it’s an AP or STA? Can those things be used to build an image so the image boots up as an AP or STA with default parameters without the need to run through the wizard?

Files in /etc/config/* are modified by the UI, including the wizards, depending on the configuration set.
To modify these files at first boot, OpenWrt recommends using uci-default files. These are simply shell scripts placed in /etc/uci-defaults which run on first-boot with the primary purposes of modifying the default UCI configuration.

There are some other mechanisms littered throughout OpenWrt. If you look at some of the base-files folders in your OpenWrt source tree, you’ll see some default configuration. There is also the board.json file which OpenWrt uses to build configuration before the uci-defaults run.

If you would like to inspect exactly what configuration the wizard is changing, you can add a ?debug=1 parameter to the end of the URL - eg http://192.168.1.1/cgi-bin/luci/admin/morse/wizard?debug=1. Run through the wizard as normal, including clicking “Apply”, and eventually the wizard will exit without actually Applying the configuration. You can close the last screen and find the set of uci changes in the top right by click the Unsaved Changes indicator.
image

The wizards themselves are fairly aggressive in changing configuration, so that it is harder to get the device into a bad state as a result of preexisting settings. So expect to see a large amount of changed configuration.

1 Like

After thinking about it, I thought of looking at morsewizard.js and wizard.js to figure out if I could simply force it to be AP or client without any other information needed. Thus, I figured if you could force it to “ap” or “sta” at the start of the wizard after the user clicked the ap/client option (the one next to mesh) then show the next wizard page for that type (AP: " Setup HaLow Network - AP" or client: " Connect to a HaLow Network"), that’d be all we’d need, isn’t that right? But I was having a hard time figuring out how to override the current logic for that. Could you advise with example?
Thus, we could create 2 images: 1 for AP, 1 for client.

The wizard code is (sadly) somewhat fiddly/complex, so it won’t be the most fun to hack something together. However, you could just copy/paste the entire wizard code into two new wizards (sta/ap), figure out how to remove the first page and replace it with something like uci.set('wireless', morseInterfaceName, 'mode', 'ap'), then set luci.main.homepage to the appropriate one in a uci-defaults file (ideally a new package for each).

The problem is that if you force the user to go through the wizard anyway, it only saves a couple of clicks and still requires access to the web interface on every device. You may want to consider other mechanisms so that you don’t have to interact with the STA image at all (e.g. DPP push button or qrcode, or even a udhcpc hotplug script which lets you ‘pair’ via any ethernet cable).