I've been searching I haven't found an answer. Maybe I'm not looking the right place or what I want can't be done.
I have compiled a firmware, for a TPLink TL-WR840N v4.0, and this firmware I use in many devices. I a /etc/config/network file with my custom config, and I want to include an auto-generated ula_prefix.
I firstly installed a firmware I've downloaded from OpenWRT site, then copied config files from the router to edit and create my I custom configs. The problem is that all routers will have the same ula_prefix, and I can't find the answer to make it auto-generated. If I omit the line "option ula_prefix", it will be disabled.
Is there a way to make it auto-generated for each router I install my custom firmware?
https://openwrt.org/docs/guide-developer/uci-defaults for more details. If you're pre-populating /etc/config/network in your ROM, then something as simple as generating a random prefix and using a sed -i replacement would likely do it. There are several useful script functions available in /lib/functions.sh and /lib/functions/
I believe that the default base-files package includes a uci-defaults script (12_network-generate-ula) that does this.
I'm not a programmer so I may be completely misreading the code , but it looks to me like setting network.globals.ula_prefix to 'auto' might provide the behaviour you're looking for?
The simplest way is really to set "option ula_prefix auto" on /etc/config/network file. I have tried it but I didn't payed attemption to the fact that the script that will auto-generate it will run only once, after the first boot. So I was only rebooting the router expecting it would auto-generate without performing a factory-reset. After changing network fila with "option ula_prefix auto" and recompiling the firmware, and flashing it, then it works. Each time I perform a factory-reset it will generate a new random ula_prefix.