summary refs log tree commit diff
diff options
context:
space:
mode:
authorManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-06-01 11:59:02 +0200
committerManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-06-01 11:59:02 +0200
commit289daaf859048b4c399063f27e55bf236bb7844e (patch)
tree1a59e8e7aafda82414288d5ed8f3cbd58ca2d57f
parentFixed service file (diff)
downloadgeolocate-289daaf859048b4c399063f27e55bf236bb7844e.tar.gz
geolocate-289daaf859048b4c399063f27e55bf236bb7844e.tar.bz2
geolocate-289daaf859048b4c399063f27e55bf236bb7844e.zip
Fixed service file x2
-rwxr-xr-xgeolocate13
-rw-r--r--geolocate.service2
2 files changed, 14 insertions, 1 deletions
diff --git a/geolocate b/geolocate
index b11846f..674d242 100755
--- a/geolocate
+++ b/geolocate
@@ -35,6 +35,15 @@ curl -s https://ipvigilante.com/ | \
         done
 }
 
+printCoord() {
+curl -s https://ipvigilante.com/ | \
+        jq '.data.latitude, .data.longitude' | \
+        while read -r LATITUDE; do
+                read -r LONGITUDE
+                echo "${LATITUDE}:${LONGITUDE}" | tr -d '"' > /usr/share/geolocate/.location
+        done
+}
+
         main() {
 
             case "$1" in
@@ -65,6 +74,10 @@ curl -s https://ipvigilante.com/ | \
                   esac
                   exit 0
                 ;;
+            print)
+                printCoord
+                exit 0
+                ;;
             *)
                 getCoord
                 exit 0
diff --git a/geolocate.service b/geolocate.service
index 2cc3cb9..6527d7e 100644
--- a/geolocate.service
+++ b/geolocate.service
@@ -4,7 +4,7 @@ Wants=network-online.target
 After=network.target network-online.target
 
 [Service]
-ExecStart=/usr/bin/geolocate > /usr/share/geolocate/.location
+ExecStart=/usr/bin/geolocate print
 
 [Install]
 WantedBy=multi-use1r.target