You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
239 lines
5.5 KiB
Bash
239 lines
5.5 KiB
Bash
#!/bin/sh
|
|
|
|
. /lib/functions.sh
|
|
. /lib/functions/uci-defaults.sh
|
|
. /lib/functions/system.sh
|
|
|
|
ramips_setup_interfaces()
|
|
{
|
|
local board="$1"
|
|
|
|
case $board in
|
|
adslr,g7|\
|
|
afoundry,ew1200|\
|
|
d-team,pbr-m1|\
|
|
firefly,firewrt|\
|
|
hiwifi,hc5962|\
|
|
mediatek,ap-mt7621a-v60|\
|
|
mediatek,mt7621-eval-board|\
|
|
mqmaker,witi|\
|
|
mtc,wr1201|\
|
|
netis,wf-2881|\
|
|
phicomm,k2p|\
|
|
planex,vr500|\
|
|
samknows,whitebox-v8|\
|
|
storylink,sap-g3200u3|\
|
|
telco-electronics,x1|\
|
|
totolink,a7000r|\
|
|
unielec,u7621-06-16m|\
|
|
unielec,u7621-06-64m|\
|
|
xiaoyu,xy-c5|\
|
|
xzwifi,creativebox-v1|\
|
|
youku,yk-l2|\
|
|
zbtlink,zbt-we1326|\
|
|
zbtlink,zbt-we3526|\
|
|
zbtlink,zbt-wg2626|\
|
|
zbtlink,zbt-wg3526-16m|\
|
|
zbtlink,zbt-wg3526-32m)
|
|
ucidef_add_switch "switch0" \
|
|
"0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
|
|
;;
|
|
asiarf,ap7621-001)
|
|
ucidef_add_switch "switch0" "0:lan" "4:wan" "6@eth0"
|
|
;;
|
|
asiarf,ap7621-nv1)
|
|
ucidef_add_switch "switch0" "0:wan" "2:lan" "3:lan" "6@eth0"
|
|
;;
|
|
asus,rt-ac57u|\
|
|
mikrotik,rb750gr3|\
|
|
mikrotik,rbm33g|\
|
|
ubiquiti,edgerouterx|\
|
|
ubiquiti,edgerouterx-sfp|\
|
|
youhua,wr1200js)
|
|
ucidef_add_switch "switch0" \
|
|
"1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
|
|
;;
|
|
asus,rt-ac65p|\
|
|
asus,rt-ac85p|\
|
|
dlink,dir-860l-b1|\
|
|
elecom,wrc-1167ghbk2-s|\
|
|
elecom,wrc-1900gst|\
|
|
elecom,wrc-2533gst|\
|
|
iodata,wn-ax1167gr|\
|
|
iodata,wn-gx300gr|\
|
|
iodata,wnpr2600g)
|
|
ucidef_add_switch "switch0" \
|
|
"1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
|
|
;;
|
|
buffalo,wsr-1166dhp|\
|
|
buffalo,wsr-600dhp)
|
|
ucidef_add_switch "switch0" \
|
|
"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan:5" "6@eth0"
|
|
;;
|
|
d-team,newifi-d2|\
|
|
wevo,11acnas|\
|
|
wevo,w2914ns-v2)
|
|
ucidef_add_switch "switch0" \
|
|
"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0"
|
|
;;
|
|
edimax,rg21s)
|
|
ucidef_add_switch "switch0" \
|
|
"1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
|
|
;;
|
|
gehua,ghl-r-001)
|
|
ucidef_add_switch "switch0" \
|
|
"0:lan" "1:lan" "2:lan" "4:wan" "6@eth0"
|
|
;;
|
|
gnubee,gb-pc1|\
|
|
gnubee,gb-pc2)
|
|
ucidef_add_switch "switch0" \
|
|
"0:lan" "4:lan" "6@eth0"
|
|
;;
|
|
lenovo,newifi-d1)
|
|
ucidef_add_switch "switch0" \
|
|
"1:lan:2" "2:lan:1" "4:wan" "6@eth0"
|
|
;;
|
|
linksys,re6500)
|
|
ucidef_add_switch "switch0" \
|
|
"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "6@eth0"
|
|
;;
|
|
mikrotik,rbm11g|\
|
|
thunder,timecloud)
|
|
ucidef_add_switch "switch0"
|
|
ucidef_add_switch_attr "switch0" "enable" "false"
|
|
ucidef_set_interface_lan "eth0"
|
|
;;
|
|
netgear,ex6150|\
|
|
tplink,re350-v1|\
|
|
tplink,re650-v1)
|
|
ucidef_add_switch "switch0" \
|
|
"0:lan" "6@eth0"
|
|
;;
|
|
netgear,r6220|\
|
|
netgear,r6260|\
|
|
netgear,r6350|\
|
|
netgear,r6850|\
|
|
netgear,wndr3700-v5)
|
|
ucidef_add_switch "switch0" \
|
|
"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
|
|
;;
|
|
xiaomi,mir3g)
|
|
ucidef_add_switch "switch0" \
|
|
"2:lan:2" "3:lan:1" "1:wan" "6t@eth0"
|
|
;;
|
|
xiaomi,mir3g-v2)
|
|
ucidef_add_switch "switch0" \
|
|
"2:lan:2" "3:lan:1" "4:wan" "6@eth0"
|
|
;;
|
|
xiaomi,mir3p)
|
|
ucidef_add_switch "switch0" \
|
|
"1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
|
|
;;
|
|
*)
|
|
ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
ramips_setup_macs()
|
|
{
|
|
local board="$1"
|
|
local lan_mac=""
|
|
local wan_mac=""
|
|
local label_mac=""
|
|
|
|
case $board in
|
|
asus,rt-ac57u|\
|
|
d-team,newifi-d2|\
|
|
d-team,pbr-m1|\
|
|
elecom,wrc-1167ghbk2-s|\
|
|
elecom,wrc-1900gst|\
|
|
elecom,wrc-2533gst|\
|
|
lenovo,newifi-d1|\
|
|
phicomm,k2p|\
|
|
planex,vr500|\
|
|
samknows,whitebox-v8|\
|
|
youhua,wr1200js|\
|
|
youku,yk-l2|\
|
|
zbtlink,zbt-we3526)
|
|
wan_mac=$(mtd_get_mac_binary factory 0xe006)
|
|
;;
|
|
asus,rt-ac65p|\
|
|
asus,rt-ac85p)
|
|
wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr)
|
|
label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
|
|
;;
|
|
buffalo,wsr-1166dhp)
|
|
local index="$(find_mtd_index "board_data")"
|
|
wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
|
|
lan_mac=$wan_mac
|
|
;;
|
|
buffalo,wsr-600dhp)
|
|
# This empty case has to be kept for devices without any MAC address adjustments
|
|
;;
|
|
dlink,dir-860l-b1)
|
|
lan_mac=$(mtd_get_mac_ascii factory lanmac)
|
|
wan_mac=$(mtd_get_mac_ascii factory wanmac)
|
|
label_mac=$(cat /sys/class/ieee80211/phy1/macaddress)
|
|
;;
|
|
edimax,rg21s)
|
|
lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
|
|
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
|
|
;;
|
|
hiwifi,hc5962)
|
|
lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
|
|
label_mac=$lan_mac
|
|
[ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
|
|
wan_mac=$(macaddr_add "$lan_mac" 1)
|
|
;;
|
|
iodata,wn-ax1167gr|\
|
|
iodata,wn-gx300gr)
|
|
wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
|
|
;;
|
|
iodata,wnpr2600g)
|
|
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
|
|
label_mac=$wan_mac
|
|
;;
|
|
netgear,r6260|\
|
|
netgear,r6350|\
|
|
netgear,r6850)
|
|
wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
|
|
;;
|
|
xiaomi,mir3g)
|
|
lan_mac=$(mtd_get_mac_binary factory 0xe006)
|
|
;;
|
|
xiaomi,mir3g-v2)
|
|
wan_mac=$(mtd_get_mac_binary factory 0xe006)
|
|
label_mac=$wan_mac
|
|
;;
|
|
xiaomi,mir3p)
|
|
lan_mac=$(mtd_get_mac_binary factory 0xe006)
|
|
label_mac=$lan_mac
|
|
;;
|
|
zbtlink,zbt-we1326)
|
|
wan_mac=$(mtd_get_mac_binary factory 0xe006)
|
|
label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
|
|
;;
|
|
zbtlink,zbt-wg3526-16m|\
|
|
zbtlink,zbt-wg3526-32m)
|
|
wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
|
|
label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
|
|
;;
|
|
*)
|
|
wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
|
|
;;
|
|
esac
|
|
|
|
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
|
|
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
|
|
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
|
|
}
|
|
|
|
board_config_update
|
|
board=$(board_name)
|
|
ramips_setup_interfaces $board
|
|
ramips_setup_macs $board
|
|
board_config_flush
|
|
|
|
exit 0
|