firmware/src/packages/fff/fff-support/files/usr/sbin/show_info
Fabian Bläse 0234203bed treewide: remove ETHPORT leftovers
ETHPORT was used to configure devices with two physical ethernet ports,
one of them being connected directly to the CPU, while the other one is
connected to the internal switch of the platform.

As the GL-AR150 has been converted to the TWO_PORT codepath and no other
devices utilizes ETHPORT, remove all leftovers.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
Tested-by: Sebastian Beck <freifunk@beibecks.de>
2022-03-31 19:31:25 +02:00

234 lines
6.8 KiB
Bash
Executable File

#!/bin/sh
. /etc/firmware_release
. /lib/functions/fff/evalhoodinfo
. /lib/functions/fff/evalbytes
. /lib/functions/fff/portorder
. /lib/functions.sh # required for config_load and config_foreach
board_name=$(uci -q get board.model.name)
HOSTNAME=$(uci -q get 'fff.system.hostname')
hood="$(uci -q get "system.@system[0].hood")"
hoodid="$(uci -q get "system.@system[0].hoodid")"
format_state() {
batmanports=$(swconfig dev switch0 vlan 3 show | grep 'ports:')
clientports=$(swconfig dev switch0 vlan 1 show | grep 'ports:')
wanports=$(swconfig dev switch0 vlan 2 show | grep 'ports:')
if (echo "$clientports" | grep -q "${1}") && (echo "$batmanports" | grep -q "${1}") ; then
linkstate="Multi-Link"
elif echo "$clientports" | grep -q "${1}" ; then
linkstate="CLIENT"
elif echo "$batmanports" | grep -q "${1}" ; then
linkstate="BATMAN"
elif echo "$wanports" | grep -q "${1}" ; then
linkstate="WAN"
else
linkstate="Unknown"
fi
printf '%-11s' "$linkstate "
}
format_port() {
port=$(echo "$1" | sed 's/.* port:\([^ ]*\) .*/\1/')
link=$(echo "$1" | sed 's/.* link:\([^ ]*\).*/\1/')
if [ "$link" = "up" ] ; then
speed=$(echo "$1" | sed 's/.* speed:\([^ ]*\).*/\1/')
duplex=$(echo "$1" | sed 's/.* \([^ ]*-duplex\).*/\1/')
else
speed="no link"
duplex=""
fi
printf '%-5s%s' "${link} " "- "
format_state "${port}"
printf '%-26s' "@ $speed $duplex "
swconfig dev switch0 show | grep -E "VLAN\s[0-9]+:[ \t]*$" | while read line ; do
vid=$(echo "$line" | sed 's/.*VLAN \([^:]*\).*/\1/')
vports=$(swconfig dev switch0 vlan "$vid" show | grep 'ports:')
if echo "$vports" | grep -q "${port}t" ; then
printf '%-2s ' "t"
elif echo "$vports" | grep -q "${port}" ; then
printf '%-2s ' "u"
else
printf '%-2s ' "-"
fi
done
echo ""
}
if pidof fastd >/dev/null ; then
vpn_active="aktiv"
else
vpn_active="inaktiv"
fi
up="$(uptime)"
load="${up##*:}"
uptime="${up%%,*}"
uptime="${uptime##*up}"
#include OpenWrt version
. /etc/openwrt_release
. /etc/firmware_release
addr() {
local addr="$(ip -$1 address show dev $2 2>/dev/null | tr '/' ' '| awk '/inet/{ printf("%s ", $2); }')"
echo "${addr:--}"
}
default_gw() {
ip -$1 route list 0/0 dev $2 2> /dev/null | awk '{print($3); exit(0)}'
}
wanif=$(uci -q get network.wan.ifname)
if [ -n "$(default_gw 4 $wanif)" -o -n "$(default_gw 6 $wanif)" ]; then
internet_active="Ja"
else
internet_active="Nein"
fi
echo ""
echo "Router configuration overview:"
echo ""
echo "-> SYSTEM"
echo "Name: ${HOSTNAME}"
echo "Modell: $(cat /tmp/sysinfo/model 2>/dev/null)"
echo "MAC-Adresse: $(cat /sys/class/net/br-client/address)"
echo "Bekannte Knoten: $(($(batctl tg -H | cut -b 40-56 | sort | uniq | wc -l 2>/dev/null)+1))"
echo "Nachbarknoten: $(batctl o -H | cut -b 40-56 | sort | uniq | wc -l 2>/dev/null)"
echo "VPN via fastd: ${vpn_active}"
echo "Laufzeit: ${uptime}"
echo "Auslastung: ${load}"
echo "Uhrzeit: $(date)"
echo ""
echo "-> HOOD"
echo "Hood: ${hood} / ID: ${hoodid}"
echo "Mesh-Type (2.4/5 GHz): ${mesh_type2} / ${mesh_type5}"
echo "Channel (2.4/5 GHz): ${real_chan2ghz} / ${real_chan5ghz} (real) | ${chan2ghz} / ${chan5ghz} (Hood)"
echo "SSID (Client-AP): ${real_essid} (real) | ${essid} (Hood)"
if uci -q get wireless.w2configap > /dev/null ; then
echo "Config-AP: up"
else
echo "Config-AP: down"
fi
echo ""
echo "-> SOFTWARE"
echo "Firmware Version: ${FIRMWARE_VERSION}"
echo "LEDE Version: ${DISTRIB_DESCRIPTION}"
echo "Kernel Version: $(uname -s -m -r)"
echo "Batman-Adv Version: $(cat /sys/module/batman_adv/version 2>/dev/null)"
echo "Fastd Version: $(fastd --version 2> /dev/null | cut -d' ' -f 2)"
echo ""
echo "-> Netz: FREIFUNK"
echo "Nutzer: $(batctl tl -H 2> /dev/null | grep -c 'W')"
echo "Empfangen: $(cat /sys/class/net/br-client/statistics/rx_bytes 2> /dev/null | human_bytes)"
echo "Gesendet: $(cat /sys/class/net/br-client/statistics/tx_bytes 2> /dev/null | human_bytes)"
echo "IPv4 Adressen: $(addr 4 br-client)"
echo "IPv6 Adressen: $(addr 6 br-client)"
echo ""
if [ -d /etc/fastd/fff/peers ]; then
echo "-> FASTD: Peer list"
for fastdpeer in $(ls /etc/fastd/fff/peers); do
echo "${fastdpeer}: $(grep "remote" "/etc/fastd/fff/peers/$fastdpeer" | sed "s/remote //")"
done
else
echo "-> FASTD"
echo "No FASTD peers available"
fi
echo ""
echo "-> Netz: WAN"
echo "Internet vorhanden: ${internet_active}"
echo "Empfangen: $(cat /sys/class/net/${wanif}/statistics/rx_bytes 2> /dev/null | human_bytes)"
echo "Gesendet: $(cat /sys/class/net/${wanif}/statistics/tx_bytes 2> /dev/null | human_bytes)"
echo "IPv4 Adressen: $(addr 4 $wanif)"
echo "IPv6 Adressen: $(addr 6 $wanif)"
echo ""
echo "-> EINSTELLUNGEN"
echo "Knotenname: ${HOSTNAME}"
echo "Knotenbeschreibung: $(uci -q get 'fff.system.description')"
echo "GPS Breitengrad: $(uci -q get 'fff.system.latitude')"
echo "GPS Laengengrad: $(uci -q get 'fff.system.longitude')"
echo "Standortbeschreibung: $(uci -q get 'fff.system.position_comment')"
echo "E-Mail Adresse: $(uci -q get 'fff.system.contact')"
echo ""
echo "-> BITRATEN-BEGRENZUNG"
if [ -s "/etc/config/simple-tc" ]; then
if [ "$(uci -q get 'simple-tc.example.enabled')" = "1" ] ; then
echo "Aktiv: ja"
else
echo "Aktiv: nein"
fi
echo "Download-Limit: $(uci -q get 'simple-tc.example.limit_ingress') kBit/s"
echo "Upload-Limit: $(uci -q get 'simple-tc.example.limit_egress') kBit/s"
else
echo "simple-tc nicht installiert."
fi
portorder=$(get_port_order)
echo ""
if swconfig list | grep -q switch0 ; then
if [ -n "$portorder" ] ; then
echo "-> SWITCH (tatsaechliche Portreihenfolge)"
else
echo "-> SWITCH (interne logische Portreihenfolge)"
fi
printf '%-54s' "VLAN-IDs:"
swconfig dev switch0 show | grep -E "VLAN\s[0-9]+:[ \t]*$" | while read line ; do
vid=$(echo "$line" | sed 's/.*VLAN \([^:]*\).*/\1/')
printf '%-2s ' "$vid"
done
echo ""
echo ""
if [ ! "$(awk -F= '/WANDEV=/ { print $2 }' /etc/network.$board_name)" = "$(awk -F= '/SWITCHDEV=/ { print $2 }' /etc/network.$board_name)" ] ; then
wanif=$(uci -q get network.wan.ifname)
link=$(cat /sys/class/net/${wanif}/operstate)
if [ "$link" = "up" ] ; then
speed="connected"
else
speed="no link"
fi
printf '%-10s%-5s%-13s%s\n' "WAN-Port: " "${link} " "- WAN " "@ $speed"
fi
for internalport in $portorder
do
line=$(swconfig dev switch0 port "$internalport" show | tr -d '\n' | tr -d '\t')
port=$(echo "$line" | sed 's/.* port:\([^ ]*\) .*/\1/')
printf '%-10s' "Port #${port}: "
format_port "${line}"
done
echo ""
swconfig dev switch0 show | grep "\t*link:" | while read line ; do
line=$(echo "$line" | tr -d '\n' | tr -d '\t')
port=$(echo "$line" | sed 's/.* port:\([^ ]*\) .*/\1/')
if echo "$portorder" | grep -q "$port" ; then
continue
fi
printf '%-10s' "Port #${port}: "
format_port "${line}"
done
else
echo "-> PORT ASSIGNMENT"
if grep -q "ONE_PORT" "/etc/network.$board_name" ; then
# Device has a port set by $ETHMODE
. /etc/network.mode
. /etc/network.config
echo "Port Modus: $ETHMODE"
fi
fi
echo ""
echo "END"