OpenWrt Forum Archive

Topic: [Solved] How to config network before make?

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.

I want to configure the network first , then issue make to generate the firmware and then flash it to router.
I already know the network configuration  is stored in file /etc/config/network(on router), but I don't know how is this file generated.
For example, I know I should modify the file ~/openwrt_trunk/package/kernel/mac80211/files/lib/wifi/mac80211.sh(of course on develop host, and openwrt_trunk is my Buildroot directory) to config wifi before make (this will affect the file /etc/config/wireless(on router) ).
But could anybody tell me the corresponding file(s) to be modified to configure network before issue make?

(Last edited by 130496 on 28 Oct 2014, 11:50)

You can include "custom files" to your build in the firmware compilation or image generator usage. Use a live router and configure network & wifi etc as you like. Then store the key config files /etc/config/network etc. as <buildroot>/files/etc/config/network

http://wiki.openwrt.org/doc/howto/build#custom.files
http://wiki.openwrt.org/doc/howto/obtai … s.variable

It is much easier than trying to set individual sources files in various packages.

(Last edited by hnyman on 21 Oct 2014, 14:12)

hnyman wrote:

You can include "custom files" to your build in the firmware compilation or image generator usage. Use a live router and configure network & wifi etc as you like. Then store the key config files /etc/config/network etc. as <buildroot>/etc/config/network

http://wiki.openwrt.org/doc/howto/build#custom.files
http://wiki.openwrt.org/doc/howto/obtai … s.variable

It is much easier than trying to set individual sources files in various packages.


Thanks. I follow your first method(http://wiki.openwrt.org/doc/howto/build#custom.files), and it works.

How is it possible to include in the image built some files or packages for specific board or profile?
For examples: if I have 2 different board and I defined 2 different profiles and i want to define for them two different set of configuration files, like /etc/config/network, /etc/config/wireless and so on, or two different set of packages that must be includede in the images.
How is it possible to select and include in the images generated for the two boards the different config files or different packages on each board image?

I include my settings in a tar.gz archive file in the firmware (e.g. as custom files in <buildroot>/etc ) and then manually extract the settings after flash. You can easily include settingsABC.tar.gz, settingsCDF.tar.gz etc.. Or just create subdirs in /etc/config for each router and store settings there and manually copy them into place.


If you want avoid manual extraction work, create e.g. an uci-defaults shell script that first sniffs the router type (or serial) and then copies/extracts the correct files for that router. But that requires a bit deeper shell scripting & Openwrt knowledge.

I was expecting that all the profiles stuff present on openwrt can help me to easily configure different boards and different profiles.

I agree with your suggestions but I would avoid to make this kind of operations at firstboot, if it is possible.

If for example you put in your custom package your configuration file you, can create different configuration file with their own script to setup the board once installed. This means that you should be able to have different packages for different profiles.

But as far as I understood, it doesn't work on Openwrt.

You can put run once scripts in files/etc/uci-defaults.  This way you can change only what you need in the configuration files (using uci set / batch) as oppose to overwriting default distrabution configs.  If you want different configs depending on the hardware simply do a case on model.  There are examples of this in the existing uci-defaults scripts.

(Last edited by sailor_ca on 28 Nov 2014, 18:26)

The discussion might have continued from here.