fff-web/show_info: Put common code into function

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Reviewed-by: Tim Niemeyer <tim@tn-x.org>
This commit is contained in:
Adrian Schmutzler 2017-11-12 23:49:03 +01:00 committed by Tim Niemeyer
parent 232b8bff62
commit 8e5e7cba47
3 changed files with 17 additions and 25 deletions

View File

@ -0,0 +1,15 @@
#!/bin/sh
human_bytes() {
while read B ; do
[ $B -lt 1024 ] && echo ${B} B && return
KB=$(((B+512)/1024))
[ $KB -lt 1024 ] && echo ${KB} KB && return
MB=$(((KB+512)/1024))
[ $MB -lt 1024 ] && echo ${MB} MB && return
GB=$(((MB+512)/1024))
[ $GB -lt 1024 ] && echo ${GB} GB && return
echo $(((GB+512)/1024)) TB && return
done
echo "-"
}

View File

@ -2,24 +2,13 @@
. /etc/firmware_release
. /lib/functions/fff/evalhoodinfo
. /lib/functions/fff/evalbytes
board_name=$(uci -q get board.model.name)
HOSTNAME=$(uci -q get 'fff.system.hostname')
hood="$(uci -q get "system.@system[0].hood")"
human_bytes() {
while read B ; do
[ $B -lt 1024 ] && echo ${B} B && break
KB=$(((B+512)/1024))
[ $KB -lt 1024 ] && echo ${KB} KB && break
MB=$(((KB+512)/1024))
[ $MB -lt 1024 ] && echo ${MB} MB && break
GB=$(((MB+512)/1024))
[ $GB -lt 1024 ] && echo ${GB} GB && break
echo $(((GB+512)/1024)) TB
done
}
format_state() {
batmanports=$(swconfig dev switch0 vlan 3 show | grep 'ports:')
clientports=$(swconfig dev switch0 vlan 1 show | grep 'ports:')

View File

@ -1,19 +1,7 @@
#!/usr/bin/haserl
<%
human_bytes() {
while read B ; do
[ $B -lt 1024 ] && echo ${B} B && return
KB=$(((B+512)/1024))
[ $KB -lt 1024 ] && echo ${KB} KB && return
MB=$(((KB+512)/1024))
[ $MB -lt 1024 ] && echo ${MB} MB && return
GB=$(((MB+512)/1024))
[ $GB -lt 1024 ] && echo ${GB} GB && return
echo $(((GB+512)/1024)) TB && return
done
echo "-"
}
. /lib/functions/fff/evalbytes
show_msg() {
if [ "$MSG" != "" ] ; then