1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-13 11:01:50 +00:00
openmptcprouter-feeds/luci-app-openmptcprouter/root/bin/omr-huawei
Ycarus (Yannick Chabanois) 453d349ff3 Set timeout to get signal
2020-02-22 14:12:13 +01:00

14 lines
No EOL
909 B
Bash
Executable file

#!/bin/sh
MODEM_IP=`echo $1 | grep -E '^(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.)'`
[ -z "$MODEM_IP" ] && return
SESTOK=$(curl -s -m 1 -X GET "http://$MODEM_IP/api/webserver/SesTokInfo")
[ -z "$SESTOK" ] && return
COOKIE=$(echo $SESTOK | sed -ne '/SesInfo/{s/.*<SesInfo>\(.*\)<\/SesInfo>.*/\1/p;q;}')
COOKIE=$(echo $COOKIE | sed 's:SessionID=::')
TOKEN=$(echo $SESTOK | sed -ne '/TokInfo/{s/.*<TokInfo>\(.*\)<\/TokInfo>.*/\1/p;q;}')
curl -s -m 1 -X GET "http://$MODEM_IP/api/monitoring/status" -H "Cookie: SessionID=$COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" > /tmp/huawei-$1-status
SIGNAL_ICON=$(cat /tmp/huawei-$1-status | grep SignalIcon | sed -e 's/<[^>]*>//g')
MAX_SIGNAL=$(cat /tmp/huawei-$1-status | grep maxsignal | sed -e 's/<[^>]*>//g')
if [ -n "$SIGNAL_ICON" ] && [ -n "$MAX_SIGNAL" ]; then
echo $((100 * ${SIGNAL_ICON} / ${MAX_SIGNAL}))
fi