mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
port-management: move port population to uci-defaults
This commit is contained in:
parent
8660069566
commit
696b4b063a
1 changed files with 53 additions and 0 deletions
|
|
@ -0,0 +1,53 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /lib/network/utils.sh
|
||||||
|
|
||||||
|
populate_config(){
|
||||||
|
if [ -s "/etc/config/ports" ]; then
|
||||||
|
if uci -q get ports.@ethport[0] >/dev/null; then
|
||||||
|
# return if there is any valid content
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
rm -f /etc/config/ports
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
touch /etc/config/ports
|
||||||
|
|
||||||
|
local portorder="$(db -q get hw.board.ethernetPortOrder)"
|
||||||
|
for port in $portorder; do
|
||||||
|
uci add ports ethport
|
||||||
|
uci rename ports.@ethport[-1]="$(interfacename $port)"
|
||||||
|
uci set ports.@ethport[-1].enabled=1
|
||||||
|
uci set ports.@ethport[-1].name="$(interfacename $port)"
|
||||||
|
uci set ports.@ethport[-1].ifname="$port"
|
||||||
|
uci set ports.@ethport[-1].speed=1000
|
||||||
|
uci set ports.@ethport[-1].duplex="full"
|
||||||
|
uci set ports.@ethport[-1].autoneg=1
|
||||||
|
uci set ports.@ethport[-1].eee=0
|
||||||
|
if [ "$(db -q get hw.board.ethernetWanPort)" = "$port" ]; then
|
||||||
|
uci set ports.@ethport[-1].pause=1
|
||||||
|
uci set ports.@ethport[-1].uplink=1
|
||||||
|
else
|
||||||
|
uci set ports.@ethport[-1].pause=0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
local fiberorder="$(db -q get hw.board.fiberPortOrder)"
|
||||||
|
for fiber in $fiberorder; do
|
||||||
|
uci add ports sfpport
|
||||||
|
uci rename ports.@sfpport[-1]="$(fibername $fiber)"
|
||||||
|
uci set ports.@sfpport[-1].enabled=1
|
||||||
|
uci set ports.@sfpport[-1].name="$(fibername $fiber)"
|
||||||
|
uci set ports.@sfpport[-1].ifname="$fiber"
|
||||||
|
uci set ports.@sfpport[-1].speed=1000
|
||||||
|
uci set ports.@sfpport[-1].duplex="full"
|
||||||
|
uci set ports.@sfpport[-1].autoneg=1
|
||||||
|
uci set ports.@sfpport[-1].eee=0
|
||||||
|
done
|
||||||
|
|
||||||
|
uci commit ports
|
||||||
|
|
||||||
|
[ $DEBUG ] && cat /etc/config/ports
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -f /sbin/db -a -f /lib/db/config/hw ] && populate_config
|
||||||
Loading…
Add table
Reference in a new issue