mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Fix hilink login
This commit is contained in:
parent
b99752c4cd
commit
26a50993b9
@ -232,6 +232,7 @@ function _login() {
|
|||||||
if ! _sendRequest "api/user/state-login"; then return 1; fi
|
if ! _sendRequest "api/user/state-login"; then return 1; fi
|
||||||
pwtype=$(echo "$response" | sed -rn 's/.*<password_type>([0-9])<\/password_type>.*/\1/pi')
|
pwtype=$(echo "$response" | sed -rn 's/.*<password_type>([0-9])<\/password_type>.*/\1/pi')
|
||||||
if [ -z "$pwtype" ];then pwtype=4; fi # fallback is type 4
|
if [ -z "$pwtype" ];then pwtype=4; fi # fallback is type 4
|
||||||
|
ret=1
|
||||||
if [[ ! -z "$user" ]] && [[ ! -z "$pw" ]]; then
|
if [[ ! -z "$user" ]] && [[ ! -z "$pw" ]]; then
|
||||||
# password encoding
|
# password encoding
|
||||||
# type 3 : base64(pw) encoded
|
# type 3 : base64(pw) encoded
|
||||||
@ -251,12 +252,11 @@ function _login() {
|
|||||||
tokenlist=( $(cat $header_file | sed -rn 's/^__RequestVerificationToken:\s*([0-9a-z#]*).*$/\1/pi' | sed 's/#/ /g') )
|
tokenlist=( $(cat $header_file | sed -rn 's/^__RequestVerificationToken:\s*([0-9a-z#]*).*$/\1/pi' | sed 's/#/ /g') )
|
||||||
_getToken
|
_getToken
|
||||||
sessID=$(cat $header_file | grep -ioP 'SessionID=([a-z0-9]*)')
|
sessID=$(cat $header_file | grep -ioP 'SessionID=([a-z0-9]*)')
|
||||||
if [ ! -z "$sessID" ] && [ ! -z "$token" ]; then
|
if [ ! -z "$sessID" ] && [ ! -z "$token" ]; then ret=0; fi
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
rm -f $header_file
|
||||||
fi
|
fi
|
||||||
return 1
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
# logout of hilink device
|
# logout of hilink device
|
||||||
|
@ -14,35 +14,37 @@
|
|||||||
# zbchristian 2021
|
# zbchristian 2021
|
||||||
|
|
||||||
function _setAPIParams() {
|
function _setAPIParams() {
|
||||||
if [ ! -z "$hostip" ]; then host="$hostip"; fi
|
if [ ! -z "$hostip" ]; then host="$hostip"; fi
|
||||||
if [ ! -z "$username" ]; then user="$username"; fi
|
if [ ! -z "$username" ]; then user="$username"; fi
|
||||||
if [ ! -z "$password" ]; then pw="$password"; fi
|
if [ ! -z "$password" ]; then pw="$password"; fi
|
||||||
if [ ! -z "$simpin" ]; then pin="$simpin"; fi
|
if [ ! -z "$simpin" ]; then pin="$simpin"; fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$1" ]; then echo "none"; exit; fi
|
if [ -z "$1" ]; then echo "none"; exit; fi
|
||||||
opt="${1,,}"
|
opt="${1,,}"
|
||||||
shift
|
shift
|
||||||
|
hostip="192.168.8.1"
|
||||||
while [ -n "$1" ]; do
|
while [ -n "$1" ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-u|--user) username="$2"; shift ;;
|
-u|--user) username="$2"; shift ;;
|
||||||
-P|--password) password="$2"; shift ;;
|
-P|--password) password="$2"; shift ;;
|
||||||
-p|--pin) simpin="$2"; shift ;;
|
-p|--pin) simpin="$2"; shift ;;
|
||||||
-h|--host) hostip="$2"; shift ;;
|
-h|--host) hostip="$2"; shift ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
status="no valid option given"
|
status="no valid option given"
|
||||||
result="none"
|
result="none"
|
||||||
|
hostip="192.168.8.1"
|
||||||
if [ "$opt" = "connected" ]; then
|
if [ "$opt" = "connected" ]; then
|
||||||
source /usr/local/sbin/huawei_hilink_api.sh
|
source /usr/local/sbin/huawei_hilink_api.sh
|
||||||
if ! _initHilinkAPI; then echo "none"; exit; fi
|
|
||||||
_setAPIParams
|
_setAPIParams
|
||||||
|
if ! _initHilinkAPI; then echo "none"; exit; fi
|
||||||
result=$(_getMobileDataStatus)
|
result=$(_getMobileDataStatus)
|
||||||
_closeHilinkAPI
|
_closeHilinkAPI
|
||||||
else
|
else
|
||||||
info_file="/tmp/huawei_infos_$host.dat"
|
info_file="/tmp/huawei_infos_${hostip}_${id -u}.dat"
|
||||||
if [ -f "$info_file" ]; then
|
if [ -f "$info_file" ]; then
|
||||||
age=$(( $(date +%s) - $(stat $info_file -c %Y) ))
|
age=$(( $(date +%s) - $(stat $info_file -c %Y) ))
|
||||||
if [[ $age -gt 5 ]]; then rm -f $info_file; fi
|
if [[ $age -gt 5 ]]; then rm -f $info_file; fi
|
||||||
@ -52,11 +54,11 @@ else
|
|||||||
infos=$(cat $info_file)
|
infos=$(cat $info_file)
|
||||||
else
|
else
|
||||||
source /usr/local/sbin/huawei_hilink_api.sh
|
source /usr/local/sbin/huawei_hilink_api.sh
|
||||||
|
_setAPIParams
|
||||||
if ! _initHilinkAPI; then echo "none"; exit; fi
|
if ! _initHilinkAPI; then echo "none"; exit; fi
|
||||||
_setAPIParams
|
|
||||||
infos=$(_getAllInformations)
|
infos=$(_getAllInformations)
|
||||||
_closeHilinkAPI
|
_closeHilinkAPI
|
||||||
if [ ! -z "$infos" ]; then echo "$infos" > /tmp/huawei_infos_$host.dat; fi
|
if [ ! -z "$infos" ]; then echo "$infos" > $info_file; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
|
@ -284,7 +284,7 @@ function setClientState($state)
|
|||||||
$ipadd = $ipadd[0].'1'; // ip address of the Hilink api
|
$ipadd = $ipadd[0].'1'; // ip address of the Hilink api
|
||||||
$mode = ($state == "up") ? 1 : 0;
|
$mode = ($state == "up") ? 1 : 0;
|
||||||
$pin=$user=$pw="";
|
$pin=$user=$pw="";
|
||||||
getMobileLogin($pin,$pw,$user)
|
getMobileLogin($pin,$pw,$user);
|
||||||
exec('sudo '.RASPI_CLIENT_SCRIPT_PATH.'/onoff_huawei_hilink.sh -c '.$mode.' -h '.$ipadd.' '.$pin.' '.$user.' '.$pw);
|
exec('sudo '.RASPI_CLIENT_SCRIPT_PATH.'/onoff_huawei_hilink.sh -c '.$mode.' -h '.$ipadd.' '.$pin.' '.$user.' '.$pw);
|
||||||
break;
|
break;
|
||||||
case "ppp":
|
case "ppp":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user