From 29547b52e1d4a7a2c7d708acb911bea525e912a9 Mon Sep 17 00:00:00 2001 From: Christian Zeitnitz Date: Sun, 23 May 2021 09:04:08 +0200 Subject: [PATCH] Use Hilink API --- config/client_config/info_huawei.sh | 2 +- config/client_config/info_huawei_hilink.sh | 10 +++++----- config/client_config/switchClientState.sh | 8 +++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/config/client_config/info_huawei.sh b/config/client_config/info_huawei.sh index 540ede98..fe6c27a1 100644 --- a/config/client_config/info_huawei.sh +++ b/config/client_config/info_huawei.sh @@ -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" diff --git a/config/client_config/info_huawei_hilink.sh b/config/client_config/info_huawei_hilink.sh index 24145bef..32b27954 100644 --- a/config/client_config/info_huawei_hilink.sh +++ b/config/client_config/info_huawei_hilink.sh @@ -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 diff --git a/config/client_config/switchClientState.sh b/config/client_config/switchClientState.sh index 4d8abbf2..acdd2892 100644 --- a/config/client_config/switchClientState.sh +++ b/config/client_config/switchClientState.sh @@ -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_