File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -80,21 +80,22 @@ for file in lfs.dir(standard_path) do
8080 new_name = ' led_' .. string.lower (section [' name' ])
8181 elseif file == ' wireless' and section [' .type' ] == ' wifi-iface' then
8282 if section [' ifname' ] == nil then
83- new_name = ' wifi_' .. getUCIName (
83+ new_name = ' wifi_' .. (
8484 standard :get (' network' , section [' network' ], ' ifname' )
8585 )
8686 else
87- new_name = ' wifi_' .. getUCIName ( section [' ifname' ])
87+ new_name = ' wifi_' .. section [' ifname' ]
8888 end
8989 else
90- new_name = nextAvailableName (getUCIName ( section [' .type' ]) )
90+ new_name = nextAvailableName (section [' .type' ])
9191 end
9292 -- make sure the new name is unique
9393 if all_names [new_name ] then
9494 new_name = nextAvailableName (new_name .. ' _' )
9595 end
9696 all_names [new_name ] = true
97- section [' .name' ] = new_name
97+ -- make sure name is valid
98+ section [' .name' ] = getUCIName (new_name )
9899 section [' .anonymous' ] = false
99100 utils .write_uci_section (output , file , section )
100101 output :reorder (file , section [' .name' ], index )
Original file line number Diff line number Diff line change @@ -14,8 +14,12 @@ config interface 'lan'
1414 option ip6assign '60'
1515 option force_link '0'
1616
17+ config device
18+ option name 'eth0.2'
19+ option macaddr '00:00:00:00:00:11'
20+
1721config interface 'wan'
18- option ifname 'eth0.2'
22+ option device 'eth0.2'
1923 option proto 'none'
2024 option test_restore '1'
2125
Original file line number Diff line number Diff line change @@ -42,6 +42,9 @@ function TestUciAutoname.test_default_behaviour()
4242 -- ensure rest of config options are present
4343 luaunit .assertNotNil (string.find (networkContents , " config interface 'loopback'" ))
4444 luaunit .assertNotNil (string.find (networkContents , " config interface 'lan'" ))
45+ -- ensure device eth0.2 is renamed
46+ luaunit .assertNotNil (string.find (networkContents , " config device 'device_eth0_2'" ))
47+ luaunit .assertNotNil (string.find (networkContents , " option macaddr '00:00:00:00:00:11'" ))
4548 -- check wireless
4649 local wirelessFile = io.open (write_dir .. ' wireless' )
4750 luaunit .assertNotNil (wirelessFile )
You can’t perform that action at this time.
0 commit comments