iopsys-feed/layer2interface/broadcom/etc/init.d/layer2_interface_ethernet

57 lines
1.5 KiB
Bash
Executable file

#!/bin/sh /etc/rc.common
. /lib/functions.sh
include /lib/network
START=22
USE_PROCD=1
get_current_status() {
local port="$1"
local media="$(ethctl $port media-type 2>&1)"
if echo $media | grep "1000" >/dev/null; then
return 0
elif echo $media | grep "100" >/dev/null; then
return 1
elif echo $media | grep "10" >/dev/null; then
return 1
fi
}
boot() {
local baseifname wanport portnum
config_load layer2_interface_ethernet
config_get baseifname Wan baseifname
config_get ifname Wan ifname
[ -n "$baseifname" ] || baseifname="$(db -q get hw.board.ethernetWanPort)"
if [ "$(db get hw.board.hardware)" != "EG300" ]; then
get_current_status $baseifname
local ret=$?
if [ $ret -eq 1 ]; then
ethctl $baseifname phy-power down
ethctl $baseifname phy-power up
fi
fi
for interf in `db get hw.board.ethernetPortOrder`; do ethswctl -c wan -i $interf -o disable ; done
wanport=$(db get hw.board.ethernetWanPort)
unit=$(echo $(get_port_number $wanport) | cut -d ' ' -f 1)
port=$(echo $(get_port_number $wanport) | cut -d ' ' -f 2)
ethswctl -c pause -n $unit -p $port -v 1
ethswctl -c hw-switching -o enable
if [ $baseifname ]; then
ethswctl -c wan -i $baseifname -o enable
fi
if [ "`db get hw.board.tm`" == "1" ]; then
for interf in `db get hw.board.ethernetPortOrder`; do
tmctl porttminit --devtype ETH --if $interf --flag 1 || \
echo "ERROR: porttminit $interf failed!" > /dev/kmsg
done
fi
[ -n "$ifname" ] && echo '1' > /proc/sys/net/ipv6/conf/$baseifname/disable_ipv6
[ -n $baseifname ] && ifconfig $baseifname up
}