#!/bin/sh
. /lib/functions.sh
log() {
logger -t "Status Update" "$@"
}
levelsper="101,85,70,55,40,25,0"
namesper="Perfect,Excellent,Good,Medium,Low,Bad,Dead"
levelsrssi="1,70,90,100,119,113,0"
namesrssi="Perfect,High,Medium,Poor,Bad,None"
levelsrscp="50,70,90,100,112,136,140,0"
namesrscp='High (3G) :High (4G),Medium (3G) : High (4G),Poor (3G) : Good (4G),Weak (3G) : Medium (4G),None (3G) : Poor (4G)'
level2txt() {
tmp="$1"
key=$2
front=""
tmp1="$tmp"" "
if [ "$tmp" = "-" ]; then
namev="""--"""
return
fi
if [ $key = "per" ]; then
tmp=$(echo "$tmp" | sed -e "s/%//g")
level=$levelsper
namev=$namesper
namez=$namev
cindex=1
nindex=0
namev="-"
while [ true ]
do
levelv=$(echo "$level" | cut -d, -f$cindex)
if [ $levelv = "0" ]; then
namev="-"
break
fi
if [ "$tmp" -ge "$levelv" ]; then
nind=$((${nindex}+1))
namev=$(echo "$namez" | cut -d, -f$nind)
break
fi
cindex=$((${cindex}+1))
nindex=$((${nindex}+1))
done
css="level_"$nindex
desc="
"$namev""
namev="""$front$tmp1"""$desc
return
fi
if [ $key = "rssi" ]; then
front="-"
tmp=$(echo "$tmp" | sed -e "s/-//g")
tmp=$(echo "$tmp" | sed -e "s/dBm//g")
tmp1="$tmp"" "
level=$levelsrssi
namev=$namesrssi
namez=$namev
cindex=1
nindex=0
namev="-"
while [ true ]
do
levelv=$(echo "$level" | cut -d, -f$cindex)
if [ $levelv = "0" ]; then
namev="-"
break
fi
if [ "$tmp" -le "$levelv" ]; then
nindex=$((${nindex}+1))
namev=$(echo "$namez" | cut -d, -f$nindex)
break
fi
cindex=$((${cindex}+1))
nindex=$((${nindex}+1))
done
css="level_"$nindex
desc="
"$namev""
namev="""$front$tmp1"""$desc
return
fi
if [ $key = "rscp" ]; then
front=""
tmp=$(echo "$tmp" | sed -e "s/dBm//g")
tmp=$(echo "$tmp" | sed -e "s/([^)]*)//g")
tmp1="$tmp"" "
tmp=$(echo "$tmp" | sed -e "s/-//g")
tmp=$(echo "$tmp" | tr " " "," | cut -d, -f1 )
tmp=$(printf %.0f "$tmp")
level=$levelsrscp
namev=$namesrscp
namez=$namev
cindex=1
nindex=0
namev="-"
while [ true ]
do
levelv=$(echo "$level" | cut -d, -f$cindex)
if [ $levelv = "0" ]; then
namev="-"
break
fi
if [ "$tmp" -le "$levelv" ]; then
namev=$(echo "$namez" | cut -d, -f$nindex)
nindex=$((${nindex}-1))
break
fi
cindex=$((${cindex}+1))
nindex=$((${nindex}+1))
done
css="level_"$nindex
desc="
"$namev""
namev="""$front$tmp1"""$desc
return
fi
if [ $key = "single" ]; then
desc=""
tmp=$(echo "$tmp" | sed -e "s/dBm//g")
tmp=$(echo "$tmp" | sed -e "s/dB//g")
if [ $3 != "1" ];then
tmp=$(echo "$tmp" | sed -e "s/-//g")
fi
if [ $3 = "1" -o $3 = "0" ];then
desc="
".""
fi
namev="""$tmp"""$desc
return
fi
}
readstatus() {
modd=$1
while IFS= read -r line; do
port="$line"
read -r line
csq="$line"
read -r line
per="$line"
read -r line
rssi="$line"
read -r line
modem="$line"
read -r line
cops="$line"
read -r line
mode="$line"
read -r line
lac="$line"
read -r line
lacn="$line"
read -r line
cid="$line"
read -r line
cidn="$line"
read -r line
mcc="$line"
read -r line
mnc="$line"
read -r line
rnc="$line"
read -r line
rncn="$line"
read -r line
down="$line"
read -r line
up="$line"
read -r line
ecio="$line"
read -r line
rscp="$line"
read -r line
ecio1="$line"
read -r line
rscp1="$line"
read -r line
netmode="$line"
read -r line
cell="$line"
read -r line
modtype="$line"
read -r line
conntype="$line"
read -r line
channel="$line"
read -r line
phone="$line"
read -r line
read -r line
lband="$line"
read -r line
tempur="$line"
read -r line
proto="$line"
read -r line
pci="$line"
read -r line
sinr="$line"
break
done < /tmp/status$modd.file
}
bwdata() {
while IFS= read -r line; do
if [ $line = '0' ]; then
nodata="1"
break
else
nodata="0"
days=$line
read -r line
read -r line
tused=$line
read -r line
read -r line
tdwn=$line
read -r line
read -r line
tup=$line
read -r line
read -r line
project=$line
break
fi
done < /tmp/bwdata
}
splash=$(uci -q get iframe.iframe.splashpage)
if [ $splash = "1" ]; then
STEMP="/tmp/www/stemp.html"
STATUS="/usr/lib/iframe/status.html"
SPSTATUS="/tmp/www/splash.html"
rm -f $STEMP
cp $STATUS $STEMP
button="