diff --git a/dhiraagu-ddns/dip.sh b/dhiraagu-ddns/dip.sh index 73bab68..f4d7cab 100755 --- a/dhiraagu-ddns/dip.sh +++ b/dhiraagu-ddns/dip.sh @@ -1,11 +1,12 @@ #!/bin/bash + +#Import Credentials source .env DHIRAAGU_LOGIN_URL='https://portal.dhivehinet.net.mv/adsls/login_api' 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 \ --data-urlencode data[adsl][username]=$DHIRAAGU_USERNAME \ --data-urlencode data[adsl][password]=$DHIRAAGU_PASSWORD \ @@ -13,6 +14,7 @@ AUTH=$(curl -s -c /tmp/dcookies \ | awk -F ',' '{print $2}' \ | 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" ] then : @@ -27,7 +29,7 @@ else exit fi - +#Set DHIRAAGU_IP, login with generated cookie and some regex to extract Dhiraagu IP address DHIRAAGU_IP=$(curl -s -b /tmp/dcookies \ $DHIRAAGU_HOME_URL \ | grep 'IP Address' -A1 \ @@ -36,6 +38,8 @@ DHIRAAGU_IP=$(curl -s -b /tmp/dcookies \ | cut -f1 -d '<' \ | cut --complement -d '>' -f 1) +#Print IP address to console echo IP Address = $DHIRAAGU_IP +#Delete the cookie from /tmp directory rm /tmp/dcookies