Advertisement
Guest User

phonetracker.sh

a guest
Oct 9th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.20 KB | None | 0 0
  1. #!/bin/sh
  2. # phonetracker.sh by Martin Loewe
  3.  
  4. # Put your nextcloud server url in here
  5. URL="https://example.com/nextcloud"
  6.  
  7. # Put your Session ID in here
  8. SESSION="1234567890abcdef"
  9.  
  10. # Put your device name in here
  11. NAME="Tracked Phone"
  12.  
  13. # Put your update delay in here in seconds
  14. DELAY=20
  15.  
  16.  
  17. while :
  18.   do
  19.     FIX=$(/usr/sbin/gpsctl -s) # get GPS fix status
  20.     if [ "$FIX" = "1" ] # check if GPS fix is ok
  21.       then
  22.         LAT=$(/usr/sbin/gpsctl -i) # get latitude
  23.         if [ "$LAT" != "$LATOLD" ] # check if new latitude is different to old latitude
  24.           then
  25.             LATOLD=$LAT # set old latitude to new one
  26.             SPD=$(/usr/sbin/gpsctl -v) # get ground speed
  27.             LON=$(/usr/sbin/gpsctl -x) # get longitude
  28.             SAT=$(/usr/sbin/gpsctl -p) # get connected sattelites
  29.             ALT=$(/usr/sbin/gpsctl -a) # get altitude
  30.             ACC=$(/usr/sbin/gpsctl -u) # get accuracy
  31.             TIMESTAMP=$(/usr/sbin/gpsctl -t) # get gps timestamp
  32.             curl "$URL/index.php/apps/phonetrack/log/gpslogger/$SESSION/$NAME?lat=$LAT&lon=$LON&sat=$SAT&alt=$ALT&acc=$ACC&speed=$SPD&timestamp=$TIMESTAMP" # send data to nextcloud
  33.         fi
  34.     fi
  35.     sleep $DELAY
  36.   done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement