Skip to content
Snippets Groups Projects
Commit f26e4a62 authored by Jan-Tarek Butt's avatar Jan-Tarek Butt
Browse files

add overwrite priority for geocoordinates

parent b0a3d831
No related branches found
No related tags found
No related merge requests found
...@@ -152,16 +152,20 @@ autoadd_ipv6_address() { ...@@ -152,16 +152,20 @@ autoadd_ipv6_address() {
sync_geo_location(){ sync_geo_location(){
if [[ $(awk 'BEGIN{srand();print int(rand()*100)}') -lt 5 ]];then if [[ $(awk 'BEGIN{srand();print int(rand()*100)}') -lt 5 ]];then
mac=$(uci get wireless.mesh_radio0.macaddr) Static_location=$(uci get gluon-node-info.@location[0].static_location)
coords="$(wget -q -O - "http://${API_IPV6_ADRESS}/getcoords.php?mac=$mac")" if [ $Static_location -eq 0 ]; then
echo "$coords" | grep "[0-9]\{1,3\}\(\.[0-9]\)* [0-9]\{1,3\}\(\.[0-9]\)*" mac=$(uci get wireless.mesh_radio0.macaddr)
if [ "$?" = "0" ]; then coords="$(wget -q -O - "http://${API_IPV6_ADRESS}/getcoords.php?mac=$mac")"
lat="$(echo "$coords" | cut -d'|' -f1)" echo "$coords" | grep "[0-9]\{1,3\}\(\.[0-9]\)* [0-9]\{1,3\}\(\.[0-9]\)*"
lon="$(echo "$coords" | cut -d'|' -f2)" if [ "$?" = "0" ]; then
uci set gluon-node-info.@location[0].latitude=$lat lat="$(echo "$coords" | cut -d'|' -f1)"
uci set gluon-node-info.@location[0].longitude=$lon lon="$(echo "$coords" | cut -d'|' -f2)"
uci set gluon-node-info.@location[0].share_location=1 uci set gluon-node-info.@location[0].auto_location=0
uci commit gluon-node-info.@location[0] 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].share_location=1
uci commit gluon-node-info.@location[0]
fi
fi fi
fi fi
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment