firmware/src/packages/fff/fff-web/files/www/ssl/cgi-bin/home.html

120 lines
4.5 KiB
HTML
Executable File

#!/usr/bin/haserl
<%
# read from keyxchangev2data
. /lib/functions/fff/evalhoodinfo
# prepare
if [ "$REQUEST_METHOD" = "POST" ] ; then
if [ "$POST_resethood" != "" ] ; then
# reset hood
rm "$hoodfileref" 2> /dev/null
MSG='<span class="green">Hood-Daten werden innerhalb von 5 Minuten neu prozessiert.</span>'
fi
fi
%>
<%in /www/include/header %>
<%in /www/include/helpers %>
<% show_msg %>
<%
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<br />", $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
if ! fastd_pub=$(echo "secret \"$(uci -q get fastd.fff.secret)\";" | fastd -c - --show-key --machine-readable); then
fastd_pub="-"
fi
%>
<table style="width: 100%;">
<tr><td>
<fieldset style="padding-bottom:12px">
<legend>System</legend>
<table>
<tr><th>Name:</th><td><%= ${HOSTNAME} %></td></tr>
<tr><th>Modell:</th><td><% cat /tmp/sysinfo/model 2>/dev/null %></td></tr>
<tr><th>MAC-Adresse:</th><td><%= $(cat /sys/class/net/br-client/address) %></td></tr>
<tr><th>Bekannte Knoten:</th><td><%= $(($(batctl tg -H | cut -b 40-56 | sort | uniq | wc -l 2>/dev/null)+1)) %></td></tr>
<tr><th>Nachbarknoten:</th><td><%= $(batctl o -H | cut -b 40-56 | sort | uniq | wc -l 2>/dev/null) %></td></tr>
<tr><th>VPN via fastd:</th><td><%= ${vpn_active} %></td></tr>
<tr><th>fastd public key:</th><td><%= ${fastd_pub} %></td></tr>
<tr><th>Laufzeit:</th><td><%= ${uptime} %></td></tr>
<tr><th>Auslastung:</th><td><%= ${load} %></td></tr>
<tr><th>Uhrzeit:</th><td><% date %></td></tr>
</table>
</fieldset>
<fieldset style="padding-bottom:12px">
<legend>Netz: Freifunk</legend>
<table>
<tr><th>Nutzer:</th><td><% batctl tl -H 2> /dev/null | grep -c 'W' %></td></tr>
<tr><th>Empfangen:</th><td><% cat /sys/class/net/br-client/statistics/rx_bytes 2> /dev/null | human_bytes %></td></tr>
<tr><th>Gesendet:</th><td><% cat /sys/class/net/br-client/statistics/tx_bytes 2> /dev/null | human_bytes %></td></tr>
<tr><th>IPv4 Adressen:</th><td><% addr 4 br-client %></td></tr>
<tr><th>IPv6 Adressen:</th><td><% addr 6 br-client %></td></tr>
</table>
</fieldset>
</td><td>
<fieldset style="padding-bottom:12px">
<legend>Software</legend>
<table>
<tr><th>Firmware Version:</th><td><%= ${FIRMWARE_VERSION} %></td></tr>
<tr><th>OpenWrt Version:</th><td><%= ${DISTRIB_DESCRIPTION} %></td></tr>
<tr><th>Kernel Version:</th><td><% uname -s -m -r %></td></tr>
<tr><th>Batman-Adv Version:</th><td><% cat /sys/module/batman_adv/version 2>/dev/null %></td></tr>
<tr><th>Fastd Version:</th><td><% fastd --version 2> /dev/null | cut -d' ' -f 2 %></td></tr>
</table>
</fieldset>
<form method="post">
<fieldset style="padding-bottom:12px">
<legend>Hood</legend>
<table>
<tr><th style="width:200px">Hood:</th><td><% echo "$hood" %></td></tr>
<tr><th style="width:200px">Mesh-Type (2.4/5 GHz):</th><td><% echo "${mesh_type2} / ${mesh_type5}" %></td></tr>
<tr><th style="width:200px">Channel (2.4/5 GHz):</th><td>Ger&auml;t: <% echo "${real_chan2ghz} / ${real_chan5ghz}" %> | Hood: <% echo "${chan2ghz} / ${chan5ghz}" %></td></tr>
<tr><th style="width:200px">SSID (Client-AP):</th><td>Ger&auml;t: <% echo "${real_essid}" %> | Hood: <% echo "${essid}" %></td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2">Beim Klicken werden die Hood-Daten innerhalb von 5 Minuten neu abgerufen und angewandt:</td></tr>
<tr><td colspan="2"><input type="submit" name="resethood" value="Reset hood data" /></td></tr>
</table>
</fieldset>
</form>
<fieldset style="padding-bottom:12px">
<legend>Netz: WAN</legend>
<table>
<tr><th>Internet vorhanden:</th><td><%= ${internet_active} %></td></tr>
<tr><th>Empfangen:</th><td><% cat /sys/class/net/${wanif}/statistics/rx_bytes 2> /dev/null | human_bytes %></td></tr>
<tr><th>Gesendet:</th><td><% cat /sys/class/net/${wanif}/statistics/tx_bytes 2> /dev/null | human_bytes %></td></tr>
<tr><th>IPv4 Adressen:</th><td><% addr 4 $wanif %></td></tr>
<tr><th>IPv6 Adressen:</th><td><% addr 6 $wanif %></td></tr>
</table>
</fieldset>
</td></tr>
</table>
<%in /www/include/footer %>