firmware/src/packages/fff/fff-support/files/usr/sbin/show_info
Adrian Schmutzler 3214388680 treewide: rename br-mesh to br-client
The name br-mesh is actually quite misleading, since the bridge
actually includes the "client" interfaces. In order to make this
obvious, and to prevent confusion with the properly named wXmesh
interfaces, rename them to br-client.

Note that br-mesh is also particularly disturbing for the layer 3
firmware without batman-adv.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Acked-by: Fabian Bläse <fabian@blaese.de>
Acked-by: Christian Dresel <freifunk@dresel.systems>
Reviewed-by: Robert Langhammer <rlanghammer@web.de>
2020-12-22 13:41:44 +01:00

235 lines
7.0 KiB
Bash
Executable File

#!/bin/sh
. /etc/firmware_release
. /lib/functions/fff/evalhoodinfo
. /lib/functions/fff/evalbytes
. /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
if grep -q 'PORTORDER=' /etc/network.$board_name ; then
portorder=$(awk -F= '/PORTORDER=/ { print $2 }' /etc/network.$board_name | sed "s/\"//g")
fi
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" || grep -q "ETHPORT" "/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"