gwinfo: Bump to version 1.4.3

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2018-08-28 22:41:21 +02:00
parent 424b944254
commit 2b8b267ed2
2 changed files with 18 additions and 7 deletions

View File

@ -6,6 +6,10 @@
#
# designed for GATEWAY FIRMWARE
#
# v1.4.3 - 2018-08-28
# - Added version to json
# - GW-Firmware: Only append IPv4/IPv6/DHCP to bat0
#
# v1.4.2 - 2018-08-28
# - Fixed IPv4 sed to ignore subnet mask
# - Check for multiple IPv6 addresses
@ -45,7 +49,7 @@ statslink="$(uci -q get gateway.@gateway[0].statslink)"
# Code
tmp=$(/bin/mktemp)
echo "{\"hostname\":\"$hostname\",\"stats_page\":\"$statslink\",\"netifs\":[" > $tmp
echo "{\"version\":\"1.4\",\"hostname\":\"$hostname\",\"stats_page\":\"$statslink\",\"netifs\":[" > $tmp
comma=""
for netif in $(ls /sys/class/net); do
@ -55,12 +59,16 @@ for netif in $(ls /sys/class/net); do
mac="$(cat "/sys/class/net/$netif/address")"
batctl="$("$batctlpath" -m "$netif" if | grep "eth" | sed -n 's/:.*//p')"
ipv4="$(ip -4 addr show dev br-mesh | grep " 10\." | sed 's/.*\(10\.[^ ]*\/[^ ]*\) .*/\1/')"
ipv6="$(ip -6 addr show dev br-mesh | grep " fd43" | grep '::' | sed 's/.*\(fd43[^ ]*\) .*/\1/')"
[ "$(echo "$ipv6" | wc -l)" = "1" ] || ipv6=""
dhcpstart="$(uci -q get dhcp.mesh.start)"
ipv4=""
ipv6=""
dhcpstart=""
dhcpend=""
if [ "$netif" = "bat0" ]; then
ipv4="$(ip -4 addr show dev br-mesh | grep " 10\." | sed 's/.*\(10\.[^ ]*\/[^ ]*\) .*/\1/')"
ipv6="$(ip -6 addr show dev br-mesh | grep " fd43" | grep '::' | sed 's/.*\(fd43[^ ]*\) .*/\1/')"
[ "$(echo "$ipv6" | wc -l)" = "1" ] || ipv6=""
dhcpstart="$(uci -q get dhcp.mesh.start)"
fi
echo "$comma{\"mac\":\"$mac\",\"netif\":\"$netif\",\"vpnif\":\"$batctl\",\"ipv4\":\"$ipv4\",\"ipv6\":\"$ipv6\",\"dhcpstart\":\"$dhcpstart\",\"dhcpend\":\"$dhcpend\"}" >> $tmp
comma=","

View File

@ -6,6 +6,9 @@
#
# designed for GATEWAY SERVER
#
# v1.4.3 - 2018-08-28
# - Added version to json
#
# v1.4.2 - 2018-08-28
# - Fixed IPv4 sed to ignore subnet mask
# - Check for multiple IPv6 addresses
@ -45,7 +48,7 @@ dhcp=1 # 0=disabled, 1=dnsmasq, 2=isc-dhcp-server
# Code
tmp=$(/bin/mktemp)
echo "{\"hostname\":\"$hostname\",\"stats_page\":\"$statslink\",\"netifs\":[" > $tmp
echo "{\"version\":\"1.4\",\"hostname\":\"$hostname\",\"stats_page\":\"$statslink\",\"netifs\":[" > $tmp
comma=""
for netif in $(ls /sys/class/net); do