Commit 0da5b8ec authored by fuzzle's avatar fuzzle

some cleanup

parent caacc610
just some commands,
additions, sripts and hints for a easier life with
freifunk maintainance
and other magic
#!/bin/sh
#
# get bat-hosts in /etc
echo "cd tmp"
echo "wget https://freiburg.freifunk.net/ffmap-backend/nodelist.json"
echo "cat nodelist.json |grep -o -E \"id\":\ \".[^}]*|sed s/\"id\":\ \"// | sed s/\",\ \"name\":\ \"/\ / | sed s/\"// | sed 's/[a-h0-9][a-h0-9]/&:/5' | sed '
s/[a-h0-9][a-h0-9]/&:/4' | sed 's/[a-h0-9][a-h0-9]/&:/3' | sed 's/[a-h0-9][a-h0-9]/&:/2' | sed 's/[a-h0-9][a-h0-9]/&:/1' > /etc/bat-hosts"
# annoying buggy if name is given twice like fffr or CCCfr or Marienbad .. the lines should be modified/deleted
# batctl gives plenty of warnings with each command-call
#!/bin/bash
#
# simple code to get geo out of mix of macs
if [ $# != 1 ]; then
echo "usage of geoguess: $0 <node_ip>"
exit 1
fi
# debuglevel
debug=true
# get key out of keyfile
apikey=$(cat geoapikey)
# if there is no API Keyfile use test instead (limited!)
: ${apikey:=test}
# first get some macs from node, and ignore hostkeychecking
# macs=$(ssh -lroot $1 -o LogLevel=quiet -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "iwinfo phy0 scan |grep -o -E [0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}")
scp get_geo_requestmaker.sh root@[$1]:/tmp/georequest.sh
ssh -lroot $1 -o LogLevel=quiet -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "/tmp/georequest.sh" > /tmp/georequest
# make nice POST-string snippet out of it
string=$(echo -n $(for mac in $macs; do echo -n "{\"macAddress\": \"$mac\"},"; done))
string=$(echo ${string%?})
# make POST Wget request to mozilla
# https://mozilla.github.io/ichnaea/api/geolocate.html
# basicly something like:
# wget -O geodata https://location.services.mozilla.com/v1/geolocate?key=test --post-data='{ "wifiAccessPoints": [{"macAddress": "00:00:11:22:33:44"},{"macAddress": "00:00:55:66:77:88"}]}'
# wget -q -O geodata https://location.services.mozilla.com/v1/geolocate?key=$apikey --post-data="{ \"wifiAccessPoints\": [$(echo -n $string)]}"
# wget -q -O geodata https://location.services.mozilla.com/v1/geolocate?key=$apikey --post-file=/tmp/georequest
wget -q -O geodata https://location.services.mozilla.com/v1/geolocate?key=$apikey --post-data="$(cat /tmp/georequest)"
# sample output is something like
# {"location": {"lat": 48.0006632, "lng": 7.8236051}, "accuracy": 960.0275115}
# cat geodata
lat=$(cat geodata |grep -o 4[6-9].[0-9]* |head -n1)
lon=$(cat geodata |grep -o " [6-9].[0-9]*" |grep -o "[6-9].[0-9]*" |head -n1)
echo "you may try http://www.openstreetmap.org/?mlat=$lat&mlon=$lon#map=16/$lat/$lon&layers=N"
echo "or use this on router:"
echo "ssh -lroot $1 \"uci set gluon-node-info.@location[0].latitude=$lat ; uci set gluon-node-info.@location[0].longitude=$lon; uci set gluon-node-info.@location[0].altitude=200; uci set gluon-node-info.@location[0].share_location=1 ; uci commit gluon-node-info\""
if [ $debug = true ]; then
echo "#### debugfoo"
echo "request is : wget -q -O geodata https://location.services.mozilla.com/v1/geolocate?key=$apikey --post-data=\"{ \\\"wifiAccessPoints\\\": [$(echo -n $string)]}\""
echo "api key is : $apikey"
echo "macs is : $macs"
echo "string becomes : $string"
echo "return is : $(cat geodata)"
echo "tmp/georequest : $(cat /tmp/georequest)"
fi
#!/bin/sh
echo "Content-Type: application/json"
echo ""
echo "{ \"wifiAccessPoints\": ["
{
for iface in $(iw list | grep -o -E phy[01]); do
iwinfo $iface scan | \
grep -o -E '(([0-9A-F]{2}:){5}[0-9A-F]{2}|Signal: *-[1-9][0-9]*)' | \
sed "s/Signal: //" | awk '/([0-9A-F]{2}:){5}[0-9A-F]{2}/{if (match($0, "([0-9A-F]{2}:){5}[0-9A-F]{2}"))printf "{\"macAddress\":\"%s\",", $0}{if (match($0, "-[1-9][0-9]*"))printf "\"signalStrength\": %s},\n", $0}'
done
} | sed '$ s/.$//'
echo "],\"considerIp\": \"false\"}"
#!/bin/bash
#
# use livecounter to add all refugee router with their wifi users
#
# todo sporthalle opfingen, test merzhausen
echo $(./livecounter.sh macs_bissier macs_walthershofener macs_loerracher macs_kaiserstuhl macs_wiesental) "(all:"$(batctl tg|grep .W.|wc -l)")"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment