mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Implement login for Hilink devices
This commit is contained in:
@@ -1,42 +1,30 @@
|
||||
#!/bin/bash
|
||||
# connect/disconnect Huawei mobile data stick in Hilink mode (e.g. E3372h)
|
||||
# ========================================================================
|
||||
# - send xml formatted string via HTTP API to stick
|
||||
# - Requires session and verification token, which is obtained by an API call
|
||||
#
|
||||
# options: -l "user":"password" - login data - DOES NOT WORK YET
|
||||
# -h 192.168.8.1 - host ip address
|
||||
# -p 1234 - PIN of SIM card
|
||||
# -c 0/1 - connect - set datamode off/on
|
||||
# options: -u, --user - user name (default "admin")
|
||||
# -P, --password - password
|
||||
# -h, --host - host ip address (default 192.168.8.1)
|
||||
# -p, --pin - PIN of SIM card
|
||||
# -c, --connect - connect 0/1 to set datamode off/on
|
||||
#
|
||||
# required software: curl, base64, sha256sum
|
||||
#
|
||||
# zbchristian 2021
|
||||
|
||||
# include the hilink API
|
||||
# include the hilink API (defaults: user=admin, host=192.168.8.1)
|
||||
source /usr/local/sbin/huawei_hilink_api.sh
|
||||
|
||||
# handle options
|
||||
|
||||
host="192.168.8.1"
|
||||
pin=""
|
||||
user=""
|
||||
pw=""
|
||||
datamode=""
|
||||
|
||||
while getopts ":c:h:l:m:p:" opt; do
|
||||
case $opt in
|
||||
h) if [[ $OPTARG =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then host="$OPTARG"; fi
|
||||
;;
|
||||
p) if [[ $OPTARG =~ ^[0-9]{4,8} ]]; then pin="$OPTARG"; fi
|
||||
;;
|
||||
l) if [[ $OPTARG =~ ^[0-9a-zA-Z]*:.*$ ]]; then
|
||||
user=$(echo "$OPTARG" | cut -d':' -f1);
|
||||
pw=$(echo "$OPTARG" | cut -d':' -f2);
|
||||
fi
|
||||
;;
|
||||
c) if [[ $OPTARG == "1" ]]; then datamode=1; else datamode=0; fi
|
||||
;;
|
||||
esac
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
-u|--user) user="$2"; shift ;;
|
||||
-P|--password) pw="$2"; shift ;;
|
||||
-p|--pin) if [[ $2 =~ ^[0-9]{4,8} ]]; then pin="$2"; fi; shift ;;
|
||||
-h|--host) host="$2"; shift ;;
|
||||
-c|--connect) if [ "$2" = "1" ]; then datamode=1; else datamode=0; fi; shift ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
echo "Hilink: switch device at $host to mode $datamode" | systemd-cat
|
||||
@@ -44,7 +32,7 @@ echo "Hilink: switch device at $host to mode $datamode" | systemd-cat
|
||||
status="usage: -c 1/0 to disconnect/disconnect"
|
||||
if [ -z "$datamode" ] || [ ! _initHilinkAPI ]; then echo "Hilink: failed - return status: $status"; exit; fi
|
||||
|
||||
if ! _switchMobileData "$datamode"; then echo "Hilink: could not switch the data mode on/off . Error: ";_getErrorText; fi
|
||||
if ! _switchMobileData "$datamode"; then echo -n "Hilink: could not switch the data mode on/off . Error: ";_getErrorText; fi
|
||||
|
||||
if ! _closeHilinkAPI; then echo -n "Hilink: failed - return status: $status . Error: ";_getErrorText; fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user