-
Notifications
You must be signed in to change notification settings - Fork 0
/
hilink.sh
148 lines (145 loc) · 4.42 KB
/
hilink.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#! /bin/sh
scheme=${HILINK_PROTO:-'http'}
host=${HILINK_HOST:-'192.168.8.1'}
port=${HILINK_PORT:-'80'}
curl_options="-fsSH 'Host:Hi.link'"
# Get a cookie/session id
RESPONSE=`curl $curl_options -X GET $scheme://$host:$port/api/webserver/SesTokInfo`
COOKIE=`echo "$RESPONSE"| grep SessionID=| cut -b 10-147`
TOKEN=`echo "$RESPONSE"| grep TokInfo| cut -b 10-41`
case "$1" in
connect)
curl $curl_options \
-X POST "$scheme://$host:$port/api/dialup/dial" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN" \
-d"<request><Action>1</Action></request>"
;;
disconnect)
curl $curl_options \
-X POST "$scheme://$host:$port/api/dialup/dial" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN" \
-d "<request><Action>1</Action></request>"
;;
send_sms)
curl $curl_options \
-X POST "$scheme://$host:$port/api/sms/send-sms" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN" \
-d "<request><Index>-1</Index><Phones><Phone>$2</Phone></Phones><Sca>$sca</Sca><Content>$3</Content><Length>${#3}</Length><Reserved>1</Reserved><Date>$(date '+%Y-%m-%d %T')</Date></request>"
;;
get_sms)
curl $curl_options \
-X POST "$scheme://$host:$port/api/sms/sms-list" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN" \
-d "<request><PageIndex>1</PageIndex><ReadCount>${2:-1}</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>0</UnreadPreferred></request>"
;;
delete_sms)
curl $curl_options \
-X POST "$scheme://$host:$port/api/sms/send-sms" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN" \
-d "<request><Index>$2</Index></request>"
;;
sms_inbox)
$0 get_sms 50
;;
sms_count)
curl $curl_options \
-X GET "$scheme://$host:$port/api/sms/sms-count" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN"
;;
traffic_statistics)
curl $curl_options \
-X GET "$scheme://$host:$port/api/monitoring/traffic-statistics" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN"
;;
check_notifications)
curl $curl_options \
-X GET "$scheme://$host:$port/api/monitoring/check-notifications" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN"
;;
status)
curl $curl_options \
-X GET "$scheme://$host:$port/api/monitoring/status" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN"
;;
dialup_connection)
curl $curl_options \
-X GET "$scheme://$host:$port/api/dialup/connection" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN"
;;
device_information)
curl $curl_options \
-X GET "$scheme://$host:$port/api/device/information" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN"
;;
send_ussd)
curl $curl_options \
-X POST "$scheme://$host:$port/api/ussd/send" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN" \
-d "<request><content>$2</content><codeType>CodeType</codeType><timeout></timeout></request>";
;;
check_balance)
curl $curl_options \
-X POST "$scheme://$host:$port/api/ussd/send" \
-H "Cookie:$COOKIE" \
-H "__RequestVerificationToken:$TOKEN" \
-d "<request><content>*100#</content><codeType>CodeType</codeType><timeout></timeout></request>";
;;
get_ussd)
curl $curl_options \
-X POST "$scheme://$host:$port/api/ussd/get" \
-H "Cookie: $COOKIE" \
-H "__RequestVerificationToken: $TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" \
-d "<request><content>$2</content><codeType>CodeType</codeType><timeout></timeout></request>";
;;
*)
cat >&2 << EOF
#######################
# HILINK API TOOL #
#######################
connect)
Brings the modem online
disconnect)
Brings the modem offline
send_sms)
Send an sms message
Usage: send_sms '\$mobile_number' '\$message'
get_sms)
Poll the sms inbox (prints latest msg if count undefined)
Usage: get_sms '\$count'
sms_inbox)
Print the entire inbox
Usage: get_inbox
sms_count)
Query number of SMS message
traffic_statistics)
Report traffic statistics
check_notifications)
Poll for new notification
status)
Report device status
dialup_connection)
Report dialup connection
device_information)
Report device information
send_ussd)
Send a USSD request
Usage: send_ussd '\$ussd_number'
get_ussd)
Query USSD response
Usage: get_ussd '\$ussd_number'
EOF
;;
esac