added comments to dip.sh
This commit is contained in:
parent
84ee58daa9
commit
da9f4ef7fe
@ -1,11 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#Import Credentials
|
||||||
source .env
|
source .env
|
||||||
|
|
||||||
DHIRAAGU_LOGIN_URL='https://portal.dhivehinet.net.mv/adsls/login_api'
|
DHIRAAGU_LOGIN_URL='https://portal.dhivehinet.net.mv/adsls/login_api'
|
||||||
DHIRAAGU_HOME_URL='https://portal.dhivehinet.net.mv/home'
|
DHIRAAGU_HOME_URL='https://portal.dhivehinet.net.mv/home'
|
||||||
|
|
||||||
|
#Set AUTH, login to generate cookie in /tmp directory and regext to extract AUTH status.
|
||||||
|
|
||||||
AUTH=$(curl -s -c /tmp/dcookies \
|
AUTH=$(curl -s -c /tmp/dcookies \
|
||||||
--data-urlencode data[adsl][username]=$DHIRAAGU_USERNAME \
|
--data-urlencode data[adsl][username]=$DHIRAAGU_USERNAME \
|
||||||
--data-urlencode data[adsl][password]=$DHIRAAGU_PASSWORD \
|
--data-urlencode data[adsl][password]=$DHIRAAGU_PASSWORD \
|
||||||
@ -13,6 +14,7 @@ AUTH=$(curl -s -c /tmp/dcookies \
|
|||||||
| awk -F ',' '{print $2}' \
|
| awk -F ',' '{print $2}' \
|
||||||
| cut --complement -d ':' -f 1)
|
| cut --complement -d ':' -f 1)
|
||||||
|
|
||||||
|
#Check if Dhiraagu Username and password is correct before continuing. Print error, delete the cookie and stop script if any errors.
|
||||||
if [ "$AUTH" = "1" ]
|
if [ "$AUTH" = "1" ]
|
||||||
then
|
then
|
||||||
:
|
:
|
||||||
@ -27,7 +29,7 @@ else
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#Set DHIRAAGU_IP, login with generated cookie and some regex to extract Dhiraagu IP address
|
||||||
DHIRAAGU_IP=$(curl -s -b /tmp/dcookies \
|
DHIRAAGU_IP=$(curl -s -b /tmp/dcookies \
|
||||||
$DHIRAAGU_HOME_URL \
|
$DHIRAAGU_HOME_URL \
|
||||||
| grep 'IP Address' -A1 \
|
| grep 'IP Address' -A1 \
|
||||||
@ -36,6 +38,8 @@ DHIRAAGU_IP=$(curl -s -b /tmp/dcookies \
|
|||||||
| cut -f1 -d '<' \
|
| cut -f1 -d '<' \
|
||||||
| cut --complement -d '>' -f 1)
|
| cut --complement -d '>' -f 1)
|
||||||
|
|
||||||
|
#Print IP address to console
|
||||||
echo IP Address = $DHIRAAGU_IP
|
echo IP Address = $DHIRAAGU_IP
|
||||||
|
|
||||||
|
#Delete the cookie from /tmp directory
|
||||||
rm /tmp/dcookies
|
rm /tmp/dcookies
|
||||||
|
Loading…
x
Reference in New Issue
Block a user