summaryrefslogtreecommitdiff
path: root/files/common/sbin/geolocate
diff options
context:
space:
mode:
Diffstat (limited to 'files/common/sbin/geolocate')
-rwxr-xr-xfiles/common/sbin/geolocate59
1 files changed, 0 insertions, 59 deletions
diff --git a/files/common/sbin/geolocate b/files/common/sbin/geolocate
deleted file mode 100755
index c07cce3..0000000
--- a/files/common/sbin/geolocate
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/sh -ex
-
-device=wlan0-1
-tmp=/tmp/geolocate_scratch
-
-# obtain an exclusive lock
-exec 666>>/tmp/lock/geolocate
-flock -w 5 -x 666;
-
-# list neighbour wifis
-iw dev $device scan >$tmp.scan
-
-# construct HTTP request
-( echo -n '{"request_address": true, "version": "1.1.0", "wifi_towers": ['
- egrep <$tmp.scan -o -e '^BSS [0-9a-f:]{17}' -e '^[[:space:]]SSID.*' -e '^[[:space:]]signal: [0-9.-]*' \
- | tr "\n\t" " " \
- | sed 's/BSS /\n/g' \
- | tail -n +2 \
- | cut -d' ' -f1,4,7- \
- | sed 's/^\([^ ]*\) \([^ ]*\) \(.*\) $/{"mac_address":"\1", "signal_strength":"\2", "ssid":"\3"}/' \
- | tr "\n" , \
- | sed 's/,$//'
- echo ']}'
-) >$tmp.json
-( echo "POST /loc/json HTTP/1.0
-Content-length: $(wc -c <$tmp.json)
-"
- cat $tmp.json
-) >$tmp.request
-
-# consult the ooracle
-nc www.google.com 80 <$tmp.request >$tmp.response
-
-# parse the response
-tail -n1 $tmp.response \
- | tr , "\n" \
- | egrep -o -e '"latitude":[0-9.]*' -e '"longitude":[0-9.]*' -e '"street":"[^"]*' \
- | sort \
- | egrep -o '[^:"]*$' \
- | {
- read lon
- read lat
- read street
-
-# store result
- cat <<EOF
-set system.position.lon=$lon
-set system.position.lat=$lat
-set system.position.street="$street"
-EOF
- uci batch <<EOF
-set system.position.lon=$lon
-set system.position.lat=$lat
-set system.position.street="$street"
-EOF
-}
-
-# clean up
-rm $tmp* \ No newline at end of file
contact: Jan Huwald // Impressum