Some more ideas for you:
You can also use uci-defaults to sniff out the MAC of the device, serial number, or whatever the OEM stored in the readable flash (art, sysinfo, syscfg partition) and use that as basis of configuring something.
I did that to be WNDR3700/3700v2/3800 routers a few years ago (well 8 years ago).
I set wifi options based on of the MAC address, as the MAC was part of the wifi definition at that time.
See the last script in this message from year 2012.
https://forum.archive.openwrt.org/viewtopic.php?id=28392&p=14#p185418
The last part of the script uses "dd" to read the MAC from art partition:
# Almost the same settings can be used for all my three routers
# Use hardware id to set wireless MAC address and Ipv6 segment
local name
[ -f /tmp/sysinfo/model ] && name=$(cat /tmp/sysinfo/model)
radio0=`dd if=/dev/mtdblock5 bs=1 skip=0 count=6 2>/dev/null \
| hexdump -v -e '5/1 "%02x:" 1/1 "%02x" '`
radio1=`dd if=/dev/mtdblock5 bs=1 skip=12 count=6 2>/dev/null \
| hexdump -v -e '5/1 "%02x:" 1/1 "%02x" '`
echo -e "------\nSet wireless MACs for $name"
echo -e "2.4 Ghz radio: $radio0\n5 GHz radio: $radio1"
uci set wireless.radio0.macaddr=$radio0
uci set wireless.radio1.macaddr=$radio1
uci commit wireless
The script also shows the approach that I still use: I include my own personal config, only a few files, in encrypted tar file to the image I compile and place available as a community build. So I can apply my own personal settings after a reset simply by running that script and giving the password, although the basic image only contains the public defaults as defaults after reset.
Similarly, you could do a script that selects based on MAC the correct config items from a database file included in the image.
If randomness would be allowed, you could
- ship tailored default common config files in the common firmware image.
- use uci-defaults (run at the first boot) to
- sniff the MAC or serial number with "dd" or something
- calculate the unique "host network name" from that. E.g. "wifi" + first 8 chars MD5 hash of serial (wifi13f72a23) or directly "wifi" + last 8 chars of MAC (wifi87c65d54)
- set that uci option to the wifi config file.
If you need pre-determined unique network names & passwords (for each individual device), then you need to do a bit more complex lookup from shipped/fetched database file, but you could still use MAC or serial to uniquely identify the devices in the database file.