mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
23 lines
547 B
Bash
23 lines
547 B
Bash
#!/bin/sh
|
|
|
|
[ -n "$PORT" -a -n "$LINK" ] || exit 0
|
|
|
|
case "$PORT" in
|
|
# do not generate ethport ubus event
|
|
# for wifi, dsl and brige devices
|
|
wl*|wds*|atm*|ptm*|br-*)
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
speed=0
|
|
duplex=full
|
|
|
|
if [ "$LINK" = "up" ]; then
|
|
devspeed="$(ubus -t 2 call network.device status "{\"name\":\"$PORT\"}" | jsonfilter -e @.speed)"
|
|
speed=${devspeed:0:-1}
|
|
duplex=${devspeed:0-1}
|
|
[ "$duplex" == "H" ] && duplex="half" || duplex="full"
|
|
fi
|
|
|
|
ubus send ethport "{\"ifname\":\"$PORT\",\"link\":\"$LINK\",\"speed\":\"$speed\",\"duplex\":\"$duplex\"}"
|