Pulvinar tempor cras amet ac turpis tristique tristique ... (read more)close
Pulvinar tempor cras amet ac turpis tristique tristique ... (read more)close

LukeTaylor.org Blog

Making I.T that little bit easier !

GPS/GSM/GPRS OBD vehicle tracker GPS306B / 306B SMS IP HOST UPDATE SCRIPT

by in Linux Blog
  • Font size: Larger Smaller
  • Hits: 4744
  • 0 Comments
  • Subscribe to this entry
  • Print
4744

b2ap3_thumbnail_s-l500.jpg

The purpose of this Blog Entry is to show you how a script can update the IP of your Tracker if your dynamic ip changes ( and you host your own Tracking server , i.e. Traccar)

 

Most of these cheaper GPRS trackers dont allow you to set the tracking server as a DNS host name. So basically if your IP changes your car wont send the tracking data to your server and you will have to manually update it via TXT . Another possible benefit of this script is it automates a SMS response and your tracker will reply to it ( which means your simcard will have SMS activity and wont expire)

 

The original script was found HERE , this was aimed I think at the USA market . This script is aimed more at the UK market.

The provider who we will be using to send the free text messages out is http://www.smspi.co.uk/ , Please sign-up for an account.

Please install CURL in your Linux environment

Ok the way this script works is

1.) You install the script as a 5 min cron

2.) Every 5 mins the script checks http://ipecho.net/plain to receive your current outside IP in plain text

3.) it stores the current IP in a file located in Etc/ called .IP-cache

4.) if the IP is still current the script ends .

5.) if the IP has changed the value in .IP-cache the following command is sent to the tracker via TXT/SMSPI.co.uk

curl --data "to=PHONENUMBER&message=adminip123456 $current 5001 &hash=YOURHASHCODE" http://www.smspi.co.uk/send/

 6.) This code sends a text message to your trackers phone number setting the new ip of your tracking server including port etc .

 

 Plain and simple , i didn't edit much so hats off to "David Wayne Baxter" for creating the base script .

You can get the API HASH from your login via smsip.co.uk

 

And here is the script you need

#!/bin/sh
 
# Before using, home directory references must be modified to match invoking user.
# Additionally, run touch on ~/.ip-cache prior to first run to avoid issues.
 
cache='/etc/.ip-cache'
prev=`/bin/cat $cache`
current=`/usr/bin/wget -qO- http://ipecho.net/plain`
 
# trap possible wget error
if [ $? != 0 ]; then
   exit 1;
fi
 
# new IP found
if [ "$current" != "$prev" ]; then

curl --data "to=YOURNUMBER&message=adminip123456 $current 5001 &hash=YOURHASH" http://www.smspi.co.uk/send/
 
   # SMS was successfully delivered to Google Voice
   # (impossible to determine whether SMS was delivered to phone)
   if [ $? -eq 0 ]; then
      /bin/echo "$current" > "$cache"
      exit 0
 
   # SMS send failed
   else
      exit 1;
   fi
 
# old IP still present
else
   exit 0;
fi

 

Rate this blog entry:

Comments

  • No comments made yet. Be the first to submit a comment

Leave your comment

Guest Tuesday, 19 November 2019