Help using uci-defaults to have firstboot configuration

Hey everyone,

I want to modify the firstboot configuration, so that when I factory reset my device, my configuration prevails. Now, after some reading, it feels like uci-defaults is the way to go, however I got a bit confused as to how I may implemment this.

I have a script that turns my device into a dumb-ap, and this is what I want my firstboot config to be. The script is as follows:


#dhcp settings
uci set dhcp.lan.ignore='1'
uci commit dhcp

#firewall settings
uci del
uci add_list'lan'
uci del
uci add_list'wan6'
uci commit firewall

#network settings
uci del network.wan
uci add_list network.cfg030f15.ports='eth0'
uci del network.lan.ipaddr
uci del network.lan.netmask
uci set network.lan.proto='dhcp'
uci commit network

/etc/init.d/network restart

My first question is, where do I place this script in order for it to be ran after every firstboot? is it in /rom/etc/uci-defaults? or /etc/uci-defaults?

The name of the file needs to be right?

Am I missing anything else in order to obtain my desired result?

Thank you for your time!

Have you looked at [OpenWrt Wiki] UCI defaults?

1 Like

and have you seen

(picked some random router, ignore the package list ... )


I saw that option, but I was wondering if I could do this with a device that's already flashed. Can't I just add the script?

no, this is for flashing or reflashing.

You can omit the uci commit commands since that will be done automatically at the end of the firstboot. Restarting the network is probably unnecessary at that point also.

1 Like

I see, well that settles it then! Thank you

Good to know, thank you for the heads-up

and have you seen

Another question, if I place a package inside, does that auto include dependencies? or do I have to manually insert all dependencies?

no, dependencies will be pulled automagically.

1 Like

Hey, I don't know if this is the default behavior, but every time i reboot my device, it returns to the configs set by the uci-default script we discussed previously...
Is this supposed to happen?

then it would be pretty pointless :wink:
and not how it's supposed to work, according to The OpenWrt Firmware Selector - #341 by mwarning.

1 Like

Is this a typo in the post or in the script? There should be a space between exit and 0, or delete the line completely.

If the script succeeds, the script will be deleted for the next reboot. If it fails, it will remain in place.


It wasn't a typo! So this is what was causing the script not to be deleted! There was never an exit 0!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.