- I patch base-files/files/etc/board.d/00-default_network to remove wan port.
diff --git a/openwrt-dd/package/base-files/files/etc/board.d/99-default_network b/openwrt-dd/package/base-files/files/etc/board.d/99-default_network
index d70aa35..55d5d79 100755
@@ -10,7 +10,6 @@ board_config_update
json_is_a network object && exit 0
-[ -d /sys/class/net/eth1 ] && ucidef_set_interface_wan 'eth1'
- On device, board.json is generated without wan port.
However, /etc/config/network still has wan port.
If I remove /etc/config/network and reboot the device, /etc/config/network is generated according to board.json without wan port.
I add debug code to dump /etc/config/network before and after mount_root, it looks like there is a default /etc/config/network is existed in the generated rootfs.
I check rootfs under staging_dir, there is no 'network' generated under directory '/etc/config'.
Even though I add file 'network' to directory 'package/base-files/files/etc/config' on purpose, I can find this file under rootfs of staging_dir, but it will be replaced by the default /etc/config/network on device.
Does any one know how the default /etc/config/network is generated?
On the fly at the first boot after flashing, but only if there is no existing network confgi from sysupgrade. If there is a network config file kept in sysupgrade, then that naturally overrides the defaults (and prevents creating a new config based on defaults).
You did not mention your device.
There may be a device-specific recipe for the network config.
For example, the recipes for routers in the ipq806x target:
/etc/board.d/02_network is the file that you should patch.
The exact file may vary a bit by target, but that is the file that creates the network config.
you talk about patching
00-default_network, but your example patch is for
Thanks for your reply.
- Yes. I also modify 02_network to remove wan port, otherwise the generated board.json will have wan port.
- Sorry, it is typo. I patch 02_network and 99-default_network. From generated board.json, I think these patches are working.
- I flash factory default image to my device, it is not sysupgrade.
- I dump /etc/config/network before and after mount_root of 'package/base-files/files/lib/preinit/80_mount_root':
a. After first flash image to device, /etc/config/network will have default setting with wan port. Due to this file already existed, the device won't base on board.json to generate /etc/config/network.
b. After removing /etc/config/network, the default file only existed before mount_root. Due to this file is not existed, the device will generate /etc/config/network based on board.json.
c. Reboot device again. the default /etc/config/network still exists before mount_root. But after mount_root, it is replaced with the generated /etc/config/network based on board.json.
I wonder how this default /etc/config/network is generated? I can't fine it in rootfs of staging_dir, there must have some way to generate it when rootfs is finally created.
That 02_network is one of the scripts that contain the functions.
Here is the part where the config file is defined
I know the way to generate network based on board.json. The process is executed after preinit. My issue is that there is an existed network file before mount_root of /lib/preinit/80_mount_root.
The default file can be replaced by the modified network after first boot. Due to this file existed for the first boot, the process to generate network based on board.json can't work.
Even though I add file 'network' to directory 'package/base-files/files/etc/config' on purpose, this file won't be replaced by the file I add.