3 if [ -f /tmp
/ethernet.state1
]; then
4 rm /tmp
/ethernet.state1
6 if [ -f /tmp
/ethernet.state2
]; then
7 rm /tmp
/ethernet.state2
9 if [ -f /tmp
/ethernet.state3
]; then
10 rm /tmp
/ethernet.state3
13 # WANMAC=`nvram get wan_hwaddr` # wan mac addr
14 # VWAN=`ifconfig | grep vlan | grep "$WANMAC" | awk '{print $1}' | grep -v ":" | tail -1` # tail SORT/UNIQ
15 VWAN
=`nvram get wan_ifname` # wan vlan from nvram, this fix bug on disabled WAN state and same LAN/WAN MAC
17 VPORT
=`nvram get $VWAN'ports' | awk '{print $1}' | sed 's/[^0-9]*//g'`
18 if [ -z "$VPORT" ]; then
22 /usr
/sbin
/robocfg showports |
grep Port |
awk '{print $1" "$2" "$3}' > /tmp
/ethernet.state.tmp
25 SWAN
=`cat /tmp/ethernet.state.tmp | grep "Port $VPORT" | awk '{print $3}'`
26 echo "Port 0: $SWAN" > /tmp
/ethernet.state
27 sed -n -e "/Port $VPORT:/!p" /tmp
/ethernet.state.tmp
> /tmp
/ethernet.state1
29 MODEL
=`nvram get model`
30 if [ "$MODEL" == "R1D" ]; then
31 sed -i '/Port 1/d' /tmp
/ethernet.state1
32 sed -i '/Port 3/d' /tmp
/ethernet.state1
35 sed -i '/Port 5/d' /tmp
/ethernet.state1
36 sed -i '/Port 8/d' /tmp
/ethernet.state1
39 REVERT
=`nvram get lan_invert`
40 if [ "$REVERT" == "1" ]; then
41 cat /tmp
/ethernet.state1 |
sort -r >> /tmp
/ethernet.state2
42 exec 0< /tmp
/ethernet.state2
46 STATE
=`echo $line | awk '{print $3}'`
47 echo "Port $NUM: $STATE" >> /tmp
/ethernet.state3
52 exec 0< /tmp
/ethernet.state1
56 STATE
=`echo $line | awk '{print $3}'`
57 echo "Port $NUM: $STATE" >> /tmp
/ethernet.state3
62 cat /tmp
/ethernet.state3
>> /tmp
/ethernet.state
64 if [ -f /tmp
/ethernet.state1
]; then
65 rm /tmp
/ethernet.state1
67 if [ -f /tmp
/ethernet.state2
]; then
68 rm /tmp
/ethernet.state2
70 if [ -f /tmp
/ethernet.state3
]; then
71 rm /tmp
/ethernet.state3