From 93c2b22a9f1dc6d4d76102bdd30626a16a658d60 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 21 Mar 2006 09:33:44 +0000 Subject: [PATCH] S05nvram cleanup SVN-Revision: 3424 --- .../base-files/default/etc/init.d/S05nvram | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/openwrt/package/base-files/default/etc/init.d/S05nvram b/openwrt/package/base-files/default/etc/init.d/S05nvram index dd2ea6866d..f5e58e072c 100755 --- a/openwrt/package/base-files/default/etc/init.d/S05nvram +++ b/openwrt/package/base-files/default/etc/init.d/S05nvram @@ -3,7 +3,6 @@ # # This file handles the NVRAM quirks of various hardware. -. /etc/nvram.overrides alias debug=${DEBUG:-:} remap () { @@ -27,11 +26,15 @@ nvram_set() { # for the linksys fixup part } } +fixup_lan() { # fix for wrong lan_ifnames default + lan_ifnames="$(nvram get lan_ifnames)" + [ "${lan_ifnames%% *}" = "$1" ] || \ + nvram set lan_ifnames="$2" +} + # work around braindead CFE defaults in linksys routers boardtype=$(nvram get boardtype) boardnum=$(nvram get boardnum) -product_name=$(nvram get product_name) - boardflags=$(($(nvram get boardflags))) adm_switch="$(( ($boardflags & 0x80) >> 7 ))" @@ -73,20 +76,22 @@ nvram set lan_proto="static" [ "$boardnum" = "42" \ -a "$boardtype" = "bcm94710dev" ] && { debug "### wrt54g 1.x hack ###" - nvram set vlan1hwname="et0" - nvram set vlan2hwname="et0" remap eth0 vlan2 remap eth1 vlan1 + nvram_default vlan1hwname "et0" + nvram_default vlan2hwname "et0" + nvram_default lan_ifnames "vlan2 eth2" } # hacks for asus wl-500g deluxe [ "$boardnum" = "45" \ -a "$boardtype" = "bcm95365r" ] && { debug "### wl-500g deluxe hacks ###" - nvram set vlan0hwname="et0" - nvram set vlan1hwname="et0" remap eth0.1 vlan0 remap eth0 vlan1 + nvram_default vlan0hwname "et0" + nvram_default vlan1hwname "et0" + nvram_default lan_ifnames "vlan0 eth1" # set up the vlan*ports variables for the asus wl-500g deluxe # if they don't already exist @@ -95,32 +100,29 @@ nvram set lan_proto="static" } # hacks for asus -case "$(nvram get productid)" in - WL300g) - debug "### wl-300g hacks ###" - nvram set lan_ifnames="eth0 eth2" - nvram set wan_ifname="none" - ;; - WLHDD) - debug "### wl-hdd hacks ###" - nvram set lan_ifnames="eth1 eth2" - nvram set wan_ifname="none" - ;; - *) - # wl-500g defaults. these are placed here, because WL-HDD and WL-300g - # might have the same nvram settings. - [ "$boardnum" = "asusX" \ - -a "$boardtype" = "bcm94710dev" ] && { - nvram_default wan_device "eth1" - } - ;; -esac +[ "$boardnum" = "asusX" ] && { + debug "### asus hacks ###" + case "$(($(nvram get et1phyaddr)))" in + 1) # WL-HDD + lan=eth1 + wan=none + ;; + *) + lan=eth0 + [ "$boardtype" = "bcm94710dev" ] && wan=eth1 || wan=none + ;; + esac + + fixup_lan "$lan" "$lan eth2" + nvram_default wan_ifname "$wan" +} # hacks for wap54g hardware [ "$boardnum" = "2" \ -o "$boardnum" = "1024" ] && { debug "### wap54g hack ###" - nvram set wan_ifname="none" + nvram_default wan_ifname "none" + nvram_default lan_ifnames "eth0 eth1" } # hacks for buffalo wla2-g54l @@ -128,8 +130,8 @@ esac -a "$product_name" = "Product_name" \ -o "$product_name" = "WLA2-G54L" ] && { debug "### wla2-g54l hacks ###" - nvram set wan_ifname="none" - nvram set lan_ifnames="vlan0" + nvram_default wan_ifname "none" + fixup_lan "vlan0" "vlan0 eth1" } # wrtsl54gs vlan defaults @@ -147,9 +149,9 @@ esac nvram_default wl0id 0x4320 } -# defaults +# defaults, can be overridden by hardware-specific nvram_default commands nvram_default lan_ifname "br0" -nvram_default lan_ifnames "$FAILSAFE_ifnames" +nvram_default lan_ifnames "vlan0 eth1 eth2" nvram_default wan_ifname "vlan1" nvram_default wan_device "vlan1" -- 2.30.2