OpenWrt Forum Archive

Topic: /etc/config/* files

The content of this topic has been archived on 20 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Maybe I'm missing something or my google-fu is on the fritz, but I can't seem to figure out how/where the files that end up in /etc/config get created.

I'm doing a custom build process. Specifically I want to change the default network setup to a non-bridged config.
Currently I'm setting the default lan settings in make menuconfig (UCI-PRECONFIG -> uci-defaults). The contents of ~/base-files/etc/config/network don't seem to go over to the build-mipsel  hierachy. I'm assuming this is overridden by the make config (and maybe the makefile for the base-files dir?).

In any case, the contents of /etc/config/network on a unit ends up containing more than just the lan settings that are part of the uci-defaults (ie. VLAN, loopback, and WAN). So what I'm wondering is how does this file get created?

As an aside, I had previously modified the build so that the /etc/config/wireless file had the wireless enabled by default and used a specific SSID. Now I can't remember how (it's been a couple months), but I suspect I had simply added the file to base-files which I'm guessing disappeared when I ran a make clean (distclean?). Scratch that - I just found where I did that; I modified the ~/packages/broadcom-wl/files/lib/wifi/broadcom.sh file. Hmm, I should probably document that or find some more standard/obvious way of doing it than burying the modification out of the way in an otherwise standard package.

So I'm guessing there is another script or three that fills in the config/network file, I just haven't found it yet. Which leaves me wondering if setting up the network config to come from base-files will end up being clobbered by whatever scripts are involved here.

Any thoughts?

I seem to recall that some of the /etc/config-files are generated in a few different places. However, the easiest way to customize files in the final build is just to create a folder "files" in the parent openwrt folder. For instance, for my customized router build i have the following files and directories under the files-folder:

vahonen@desktop ~/src/openwrt $ ls -R files
files:
etc

files/etc:
config  ethers  firewall.config  fstab  hosts  passwd

files/etc/config:
network  ntpclient  qos  timezone  updatedd  wireless

I find this approach works great and is easy to maintain.

Hey!

So i would customize my network config of the image that I am building. I have at home ADSL, so i need put extra pppoe id and password line in the /etc/config/network. But i dont know how. Because the file is generated during making process. You said that I should put a files directory and an alternative network file, isn't it? And than the generating will have no effect?

Cheers, János

(Last edited by kukodajanos on 27 Feb 2011, 05:46)

Put it in <TOPDIR>/files/etc/config/network This should work!

I am also using a  <TOPDIR>/files/etc/config/network file but the lan configuration always gets overriden by the UCI-PRECONFIG section.

excerpt of  <TOPDIR>/files/etc/config/network

config 'interface' 'lan'
    option 'ifname' 'eth0'
    option 'proto' 'static'
    option 'ipaddr' '192.168.1.100'
    option 'netmask' '255.255.255.0'

If I set nothing in the UCI-PRECONFIG section, then my network configuration gets overidden, and mostly emptied so the device has no networking any more....

excerpt of cat /etc/config/network

config 'interface' 'lan'
        option 'ifname' 'eth0'

So I always have to configure the lan interface through a full UCI-PRECONFIG in the makefile

do you also see this wrong behaviour ?

(Last edited by pl9 on 27 Feb 2011, 23:27)

I am also trying to setup a default configuration for my build.  Putting config files in 'files/etc/config' works fine, however there are a couple issues with this approach.  For example, the wireless config contains an unique MAC address for the radio... so this cannot be hard-coded in the config file (or it will only work on the 1 router with the matching MAC).  Another approach is to create uci-defaults scripts (etc/uci-defaults) to only modify what is needed.  Here's an example of my 'etc/uci-defaults/qos' script:

#!/bin/sh

uci batch <<EOF
set qos.wan.upload=512
set qos.wan.download=2048
set qos.wan.enabled=0
commit qos
EOF

uci commit qos

Notice that it only modifies the lines I want to change, instead of the entire config file.

I do have a problem with this though, as my wireless config is not being updated on the first boot.  I suspect this is because the wireless config is generated via 'wifi detect > /etc/config/wireless"... and this doesn't occur until after the uci-defaults scripts are executed.

Does anyone have a suggestion about how to setup the default wireless configuration?

(Last edited by LinkZ on 23 Mar 2011, 05:02)

The discussion might have continued from here.