summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xconfig.sh4
-rwxr-xr-xe3372-clear-traffic-stats.sh14
-rwxr-xr-xe3372-dataswitch-off.sh14
-rwxr-xr-xe3372-dataswitch-on.sh14
-rwxr-xr-xe3372-dhcp-setting.sh12
-rwxr-xr-xe3372-readsms-xmlstarlet.sh23
-rwxr-xr-xe3372-readsms.sh16
-rwxr-xr-xe3372-reboot.sh16
-rwxr-xr-xe3372-sendsms.sh17
-rwxr-xr-xe3372-stats.sh43
-rwxr-xr-xe3372.sh18
-rwxr-xr-xinclude.sh11
13 files changed, 92 insertions, 111 deletions
diff --git a/.gitignore b/.gitignore
index 733b8d1..8cd91b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
.idea
ses_tok.xml
+modem_status.xml \ No newline at end of file
diff --git a/config.sh b/config.sh
deleted file mode 100755
index fba78b7..0000000
--- a/config.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
-[ -z "$MODEM_IP" ] && MODEM_IP="192.168.9.1" \ No newline at end of file
diff --git a/e3372-clear-traffic-stats.sh b/e3372-clear-traffic-stats.sh
index 0463f1b..9b902d9 100755
--- a/e3372-clear-traffic-stats.sh
+++ b/e3372-clear-traffic-stats.sh
@@ -1,16 +1,14 @@
#!/bin/bash
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "$DIR/config.sh"
-curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
-COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
-TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
+get_token
curl -s -X POST "http://$MODEM_IP/api/monitoring/clear-traffic" \
- -H "Cookie: $COOKIE" \
- -H "__RequestVerificationToken: $TOKEN" \
- -H "Content-Type: text/xml" \
- -d "<request><ClearTraffic>1</ClearTraffic></request>" > modem_status.xml
+ -H "Cookie: $COOKIE" \
+ -H "__RequestVerificationToken: $TOKEN" \
+ -H "Content-Type: text/xml" \
+ -d "<request><ClearTraffic>1</ClearTraffic></request>" >modem_status.xml
cat modem_status.xml
diff --git a/e3372-dataswitch-off.sh b/e3372-dataswitch-off.sh
index 93bd985..96c0a48 100755
--- a/e3372-dataswitch-off.sh
+++ b/e3372-dataswitch-off.sh
@@ -1,16 +1,14 @@
#!/bin/bash
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "$DIR/config.sh"
-curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
-COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
-TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
+get_token
curl -s -X POST "http://$MODEM_IP/api/dialup/mobile-dataswitch" \
- -H "Cookie: $COOKIE" \
- -H "__RequestVerificationToken: $TOKEN" \
- -H "Content-Type: text/xml" \
- -d "<request><dataswitch>0</dataswitch></request>" > modem_status.xml
+ -H "Cookie: $COOKIE" \
+ -H "__RequestVerificationToken: $TOKEN" \
+ -H "Content-Type: text/xml" \
+ -d "<request><dataswitch>0</dataswitch></request>" >modem_status.xml
cat modem_status.xml
diff --git a/e3372-dataswitch-on.sh b/e3372-dataswitch-on.sh
index 93ac50b..ce64652 100755
--- a/e3372-dataswitch-on.sh
+++ b/e3372-dataswitch-on.sh
@@ -1,16 +1,14 @@
#!/bin/bash
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "$DIR/config.sh"
-curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
-COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
-TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
+get_token
curl -s -X POST "http://$MODEM_IP/api/dialup/mobile-dataswitch" \
- -H "Cookie: $COOKIE" \
- -H "__RequestVerificationToken: $TOKEN" \
- -H "Content-Type: text/xml" \
- -d "<request><dataswitch>1</dataswitch></request>" > modem_status.xml
+ -H "Cookie: $COOKIE" \
+ -H "__RequestVerificationToken: $TOKEN" \
+ -H "Content-Type: text/xml" \
+ -d "<request><dataswitch>1</dataswitch></request>" >modem_status.xml
cat modem_status.xml
diff --git a/e3372-dhcp-setting.sh b/e3372-dhcp-setting.sh
index bc2f237..9bd0fe6 100755
--- a/e3372-dhcp-setting.sh
+++ b/e3372-dhcp-setting.sh
@@ -1,15 +1,13 @@
#!/bin/bash
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "$DIR/config.sh"
-curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
-COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
-TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
+get_token
curl -s -X GET "http://$MODEM_IP/api/dhcp/settings" \
- -H "Cookie: $COOKIE" \
- -H "__RequestVerificationToken: $TOKEN" \
- -H "Content-Type: text/xml" > modem_status.xml
+ -H "Cookie: $COOKIE" \
+ -H "__RequestVerificationToken: $TOKEN" \
+ -H "Content-Type: text/xml" >modem_status.xml
cat modem_status.xml
diff --git a/e3372-readsms-xmlstarlet.sh b/e3372-readsms-xmlstarlet.sh
index dd00176..6c6d901 100755
--- a/e3372-readsms-xmlstarlet.sh
+++ b/e3372-readsms-xmlstarlet.sh
@@ -1,25 +1,22 @@
-#!/bin/bash
+#!/bin/bash
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "$DIR/config.sh"
-curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
-COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
-TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
+get_token
curl -s -X POST "http://$MODEM_IP/api/sms/sms-list" \
- -H "Cookie: $COOKIE" \
- -H "__RequestVerificationToken: $TOKEN" \
- -H "Content-Type: text/xml" \
- -d "<request><PageIndex>1</PageIndex><ReadCount>10</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>" > modem_status.xml
+ -H "Cookie: $COOKIE" \
+ -H "__RequestVerificationToken: $TOKEN" \
+ -H "Content-Type: text/xml" \
+ -d "<request><PageIndex>1</PageIndex><ReadCount>10</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>" >modem_status.xml
#cat modem_status.xml
-readarray -t array_phone <<< "$(xmlstarlet sel -t -m "//Phone" -v . -n modem_status.xml)"
-readarray -t array_content <<< "$(xmlstarlet sel -t -m "//Content" -v . -n modem_status.xml)"
+readarray -t array_phone <<<"$(xmlstarlet sel -t -m "//Phone" -v . -n modem_status.xml)"
+readarray -t array_content <<<"$(xmlstarlet sel -t -m "//Content" -v . -n modem_status.xml)"
-for ((i=0; i<${#array_content[@]}; i++ ))
-do
+for ((i = 0; i < ${#array_content[@]}; i++)); do
echo -e "------\n${array_phone[$i]}"
echo -e "------\n${array_content[$i]}"
done
diff --git a/e3372-readsms.sh b/e3372-readsms.sh
index 88dfbe3..afb19f2 100755
--- a/e3372-readsms.sh
+++ b/e3372-readsms.sh
@@ -1,20 +1,18 @@
#!/bin/bash
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "$DIR/config.sh"
-curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
-COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
-TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
+get_token
curl -s -X POST "http://$MODEM_IP/api/sms/sms-list" \
- -H "Cookie: $COOKIE" \
- -H "__RequestVerificationToken: $TOKEN" \
- -H "Content-Type: text/xml" \
- -d "<request><PageIndex>1</PageIndex><ReadCount>10</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>" > modem_status.xml
+ -H "Cookie: $COOKIE" \
+ -H "__RequestVerificationToken: $TOKEN" \
+ -H "Content-Type: text/xml" \
+ -d "<request><PageIndex>1</PageIndex><ReadCount>10</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>" >modem_status.xml
#cat modem_status.xml
message=$(grep -r -E 'Phone|Content' modem_status.xml | sed -e 's/<[^>]*>//g' | sed -e 's/^[ \t]*/------\n/g')
-echo "$message\n------" \ No newline at end of file
+echo "$message\n------"
diff --git a/e3372-reboot.sh b/e3372-reboot.sh
index f727177..7b0e9e7 100755
--- a/e3372-reboot.sh
+++ b/e3372-reboot.sh
@@ -1,16 +1,12 @@
#!/bin/bash
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "$DIR/config.sh"
-curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
-COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
-TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
+get_token
curl -s -X POST "http://$MODEM_IP/api/device/control" \
- -H "Cookie: $COOKIE" \
- -H "__RequestVerificationToken: $TOKEN" \
- -H "Content-Type: text/xml" \
- -d "<?xml version='1.0' encoding='UTF-8'?><request><Control>1</Control></request>"
-
-#test \ No newline at end of file
+ -H "Cookie: $COOKIE" \
+ -H "__RequestVerificationToken: $TOKEN" \
+ -H "Content-Type: text/xml" \
+ -d "<?xml version='1.0' encoding='UTF-8'?><request><Control>1</Control></request>"
diff --git a/e3372-sendsms.sh b/e3372-sendsms.sh
index a60d946..fb13258 100755
--- a/e3372-sendsms.sh
+++ b/e3372-sendsms.sh
@@ -1,17 +1,14 @@
#!/bin/bash
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "$DIR/config.sh"
-curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
-COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
-TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
+get_token
curl -s -X POST "http://$MODEM_IP/api/sms/send-sms" \
- -H "Cookie: $COOKIE" \
- -H "__RequestVerificationToken: $TOKEN" \
- -H "Content-Type: text/xml" \
- -d "<?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>363</Phone></Phones><Sca></Sca><Content>USAGE</Content><Length>5</Length><Reserved>1</Reserved><Date>-1</Date></request>" > modem_status.xml
-
-cat modem_status.xml
+ -H "Cookie: $COOKIE" \
+ -H "__RequestVerificationToken: $TOKEN" \
+ -H "Content-Type: text/xml" \
+ -d "<?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>363</Phone></Phones><Sca></Sca><Content>USAGE</Content><Length>5</Length><Reserved>1</Reserved><Date>-1</Date></request>" >modem_status.xml
+cat modem_status.xml \ No newline at end of file
diff --git a/e3372-stats.sh b/e3372-stats.sh
index 19f560a..43e52e4 100755
--- a/e3372-stats.sh
+++ b/e3372-stats.sh
@@ -1,17 +1,14 @@
#!/bin/bash
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "$DIR/config.sh"
-curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
-COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
-TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
+get_token
curl -s -X GET "http://$MODEM_IP/api/monitoring/traffic-statistics" \
- -H "Cookie: $COOKIE" \
- -H "__RequestVerificationToken: $TOKEN" \
- -H "Content-Type: text/xml" > modem_status.xml
-
+ -H "Cookie: $COOKIE" \
+ -H "__RequestVerificationToken: $TOKEN" \
+ -H "Content-Type: text/xml" > modem_status.xml
CurConnTime=$(cat modem_status.xml | grep CurrentConnectTime | sed -e 's/<[^>]*>//g')
CurrUpload=$(cat modem_status.xml | grep "<CurrentUpload>" | sed -e 's/<[^>]*>//g')
@@ -24,13 +21,13 @@ TotalConnectTime=$(cat modem_status.xml | grep "<TotalConnectTime>" | sed -e 's/
# Current Connect Time
#------------------------------
cct_secs=$CurConnTime
-printf 'Current Connect Time : %d days: %02d hours: %02d minutes: %02d sseconds\n' $((cct_secs/86400)) $((cct_secs%86400/3600)) $((cct_secs%3600/60)) $((cct_secs%60))
+printf 'Current Connect Time : %d days: %02d hours: %02d minutes: %02d sseconds\n' $((cct_secs / 86400)) $((cct_secs % 86400 / 3600)) $((cct_secs % 3600 / 60)) $((cct_secs % 60))
#------------------------------
# Total Connect Time
#------------------------------
tct_secs=$TotalConnectTime
-printf 'Total Connect Time : %d days: %02d hours: %02d minutes: %02d sseconds\n' $((tct_secs/86400)) $((tct_secs%86400/3600)) $((tct_secs%3600/60)) $((tct_secs%60))
+printf 'Total Connect Time : %d days: %02d hours: %02d minutes: %02d sseconds\n' $((tct_secs / 86400)) $((tct_secs % 86400 / 3600)) $((tct_secs % 3600 / 60)) $((tct_secs % 60))
#cat modem_status.xml
#------------------------------
@@ -39,11 +36,11 @@ printf 'Total Connect Time : %d days: %02d hours: %02d minutes: %02d sseconds\n'
if [ $CurrUpload -lt 1024 ]; then
echo "Current Upload : ${CurrUpload}B"
elif [ $CurrUpload -lt 1048576 ]; then
- echo "Current Upload : $((CurrUpload/1024))KiB"
+ echo "Current Upload : $((CurrUpload / 1024))KiB"
elif [ $CurrUpload -lt 1073741824 ]; then
- echo "Current Upload : $((CurrUpload/1048576))MiB"
+ echo "Current Upload : $((CurrUpload / 1048576))MiB"
else
- echo "Current Upload : $((CurrUpload/1073741824))GiB"
+ echo "Current Upload : $((CurrUpload / 1073741824))GiB"
fi
#------------------------------
@@ -52,11 +49,11 @@ fi
if [ $CurrDownload -lt 1024 ]; then
echo "Current Download : ${CurrDownload}B"
elif [ $CurrDownload -lt 1048576 ]; then
- echo "Current Download : $((CurrDownload/1024))KiB"
+ echo "Current Download : $((CurrDownload / 1024))KiB"
elif [ $CurrDownload -lt 1073741824 ]; then
- echo "Current Download : $((CurrDownload/1048576))MiB"
+ echo "Current Download : $((CurrDownload / 1048576))MiB"
else
- echo "Current Dowbload : $((CurrDownload/1073741824))GiB"
+ echo "Current Dowbload : $((CurrDownload / 1073741824))GiB"
fi
#------------------------------
@@ -65,11 +62,11 @@ fi
if [ $TotalUpload -lt 1024 ]; then
echo "Total Upload : ${TotalUpload}B"
elif [ $TotalUpload -lt 1048576 ]; then
- echo "Total Upload : $((TotalUpload/1024))KiB"
+ echo "Total Upload : $((TotalUpload / 1024))KiB"
elif [ $TotalUpload -lt 1073741824 ]; then
- echo "Total Upload : $((TotalUpload/1048576))MiB"
+ echo "Total Upload : $((TotalUpload / 1048576))MiB"
else
- echo "Total Upload : $((TotalUpload/1073741824))GiB"
+ echo "Total Upload : $((TotalUpload / 1073741824))GiB"
fi
#------------------------------
@@ -78,11 +75,9 @@ fi
if [ $TotalDownload -lt 1024 ]; then
echo "Total Download : ${TotalDownload}B"
elif [ $TotalDownload -lt 1048576 ]; then
- echo "Total Download : $((TotalDownload/1024))KiB"
+ echo "Total Download : $((TotalDownload / 1024))KiB"
elif [ $TotalDownload -lt 1073741824 ]; then
- echo "Total Download : $((TotalDownload/1048576))MiB"
+ echo "Total Download : $((TotalDownload / 1048576))MiB"
else
- echo "Total Doenload : $((TotalDownload/1073741824))GiB"
+ echo "Total Doenload : $((TotalDownload / 1073741824))GiB"
fi
-
-
diff --git a/e3372.sh b/e3372.sh
index 8f298e9..350dd33 100755
--- a/e3372.sh
+++ b/e3372.sh
@@ -1,21 +1,19 @@
#!/bin/bash
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "$DIR/config.sh"
-curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
-COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
-TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
+get_token
curl -s -X GET "http://$MODEM_IP/api/device/information" \
- -H "Cookie: $COOKIE" \
- -H "__RequestVerificationToken: $TOKEN" \
- -H "Content-Type: text/xml" > modem_status.xml
+ -H "Cookie: $COOKIE" \
+ -H "__RequestVerificationToken: $TOKEN" \
+ -H "Content-Type: text/xml" >modem_status.xml
curl -s -X GET "http://$MODEM_IP/api/device/signal" \
- -H "Cookie: $COOKIE" \
- -H "__RequestVerificationToken: $TOKEN" \
- -H "Content-Type: text/xml" >> modem_status.xml
+ -H "Cookie: $COOKIE" \
+ -H "__RequestVerificationToken: $TOKEN" \
+ -H "Content-Type: text/xml" >>modem_status.xml
wmode=$(cat modem_status.xml | grep workmode | sed -e 's/<[^>]*>//g')
rssi=$(cat modem_status.xml | grep rssi | sed -e 's/<[^>]*>//g')
diff --git a/include.sh b/include.sh
new file mode 100755
index 0000000..e09000b
--- /dev/null
+++ b/include.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+[ -z "$MODEM_IP" ] && MODEM_IP="192.168.9.1"
+
+get_token() {
+ curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
+ COOKIE=$(grep "SessionID=" ses_tok.xml | cut -b 10-147)
+ TOKEN=$(grep "TokInfo" ses_tok.xml | cut -b 10-41`)
+ rm ses_tok.xml
+} \ No newline at end of file