[OpenWrt-Devel] Setting uci defaults in trunk

Felix Fietkau nbd at openwrt.org
Fri Feb 26 11:20:35 EST 2016


On 2016-02-26 15:54, micke.prag at telldus.se wrote:
> 2016-02-26 15:35 skrev Felix Fietkau:
> 
>> On 2016-02-26 15:27, micke.prag at telldus.sewrote:
>>
>>> Hi I have a board config for a device that I am about to commit to
>>> OpenWRT. I am rebasing my work against trunk but some things have
>>> changed since I made the config. My code was written against r46120 
>>> but
>>> somethings doesn't work on r48800. My question is how I should 
>>> update
>>> my code to "proper OpenWRT standard"? First, network. The board has
>>> only one network port (it is not a router). This should be 
>>> configured
>>> using DHCP. The board also has Wifi and should be configured as a
>>> client but disabled as default. In -r46120 I put this in
>>> /etc/uci-defaults/02_network: ucidef_set_interface_raw "lan" "eth0"
>>> "dhcp" ucidef_set_interface_raw "wlan" "wlan0" "dhcp" uci batch 
>>> <<EOF
>>> set network.lan.hostname='TellStick-ZNet-Lite' set
>>> wireless.radio0.disabled=0 set 
>>> wireless. at wifi-iface[0].network='wlan'
>>> set wireless. at wifi-iface[0].mode='sta' set
>>> wireless. at wifi-iface[0].encryption=psk2 EOF uci commit wireless In
>>> r48800 this file seems to have been replaced by 
>>> /etc/board.d/02_network
>>> instead. Unfortunately "raw" uci commands does not work since its
>>> generating /etc/board.json instead? Am I correct? If I do this then
>>> "dhcp" is ignored and the interface is set to static anyway:
>>> ucidef_set_interface_lan "eth0" "dhcp" How to convert the wireless 
>>> and
>>> the hostname I have no idea? Next is led. I had this in
>>> /etc/uci-defaults/02_network: ucidef_set_led_netdev "lan_act" 
>>> "LANACT"
>>> "tellstick:green:lan" "eth0" ucidef_set_led_netdev "lan_link" 
>>> "LANLINK"
>>> "tellstick:orange:lan" "eth0" uci set system.led_lan_act.mode='tx 
>>> rx'
>>> uci set system.led_lan_link.mode='link' The first two lines work in
>>> r48800 but how do I convert the last two lines? How do I set the 
>>> mode?
>>
>> To change the defaults, you shouldn't just modify the existing files.
>> You can simply create a new file in /etc/uci-defaults which runs your
>> uci batch command as usual. It will run after /etc/board.d has been
>> processed and the default config has been generated, so you should be
>> able to override any parameter you want.
> 
> The file /etc/uci-defaults/02_network was (re)moved in r47534. Is it 
> really the right way to go to reintroduce this file again?
> My thougs was that this should be implemented in /etc/board.json 
> instead, maybe I was wrong?
> 
> Please note that my goal is to have the board config sent upstream, not 
> only for my local build.
Ah, ok. I misread your intentions because of the kinds of changes you
were proposing. Some of the things you mentioned don't make sense as
board specific defaults in my opinion:
- We don't change the default host name for specific boards.
- We don't enable wireless by default or change its mode
- Interfaces using dhcp are usually considered 'wan' instead of 'lan',
LAN should have a predictable IP address.
If you believe that that any of the above changes are necessary, please
provide compelling reasons for it. Otherwise we'd prefer to keep device
configurations more consistent with each other.

As for the LED stuff: I'd suggest extending the API to make it possible
to pass the mode to ucidef_set_led_netdev so that it ends up in
board.json and can be used by /bin/config_generate.

Anything else?

- Felix
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list