Use Hilink API

This commit is contained in:
Christian Zeitnitz 2021-05-23 09:04:08 +02:00
parent 26a50993b9
commit 29547b52e1
3 changed files with 11 additions and 9 deletions

View file

@ -47,7 +47,7 @@ case $opt in
if [ ! "$res" = "none" ]; then
if [ "$type" = "hilink" ]; then
if [ "$res" = "LTE" ]; then res="4G"
elif [ "$res" = "WCDMA" ]]; then res="3G";
elif [ "$res" = "WCDMA" ]; then res="3G";
else res="2G"; fi
else
if [ $res -eq 7 ]; then res="4G"

View file

@ -21,7 +21,7 @@ function _setAPIParams() {
}
if [ -z "$1" ]; then echo "none"; exit; fi
opt="${1,,}"
property="${1,,}"
shift
hostip="192.168.8.1"
while [ -n "$1" ]; do
@ -47,7 +47,7 @@ else
info_file="/tmp/huawei_infos_${hostip}_${id -u}.dat"
if [ -f "$info_file" ]; then
age=$(( $(date +%s) - $(stat $info_file -c %Y) ))
if [[ $age -gt 5 ]]; then rm -f $info_file; fi
if [[ $age -gt 10 ]]; then rm -f $info_file; fi
fi
if [ -f "$info_file" ]; then
@ -58,10 +58,10 @@ else
if ! _initHilinkAPI; then echo "none"; exit; fi
infos=$(_getAllInformations)
_closeHilinkAPI
if [ ! -z "$infos" ]; then echo "$infos" > $info_file; fi
if [ ! -z "$infos" ]; then echo -n "$infos" > $info_file; fi
fi
case "$opt" in
case "$property" in
device|devicename)
key="devicename"
;;
@ -84,7 +84,7 @@ else
key="fullname"
;;
*)
key=""
key="device"
;;
esac
if [ -z "$key" ]; then result="none"; fi

View file

@ -7,8 +7,10 @@
# get webroot
webroot=$(cat /etc/lighttpd/lighttpd.conf | sed -rn 's/server.document-root\s*=\s*\"(.*)\"\s*$/\1/p')
if [ -z "$webroot" ] || [ ! -d "$webroot" ]; then
exit
webuser=$(cat /etc/lighttpd/lighttpd.conf | sed -rn 's/server.username\s*=\s*\"(.*)\"\s*$/\1/p')
if [ -z "$webroot" ] || [ ! -d "$webroot" ] || [ -z "$webuser" ]; then
echo "$0 : Problem to obtain webroot directory and/or web user - exit" | systemd-cat
exit
fi
cd $webroot
@ -21,7 +23,7 @@ fi
[ -z "$state" ] && exit
php << _EOF_
sudo -u $webuser php << _EOF_
<?php
require_once("includes/config.php");
require_once("includes/get_clients.php");