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

worke on geokoordinate paser

parent 61ad56c9
No related branches found
No related tags found
No related merge requests found
config 'script' config 'script'
option 'version' '1' option 'version' '1'
option 'min_quality' '70' option 'min_quality' '70'
option 'geo_num_length' '7'
# improbable sequence of numbers # improbable sequence of numbers
option 'improbability' '0000' option 'improbability' '3'
option 'mobile' 'false'
option 'pidpart' '/var/run/geolocator.pid'
...@@ -4,11 +4,28 @@ ...@@ -4,11 +4,28 @@
#If it does not exists, then get it from a normal bash file with variables. #If it does not exists, then get it from a normal bash file with variables.
if [ -f /etc/config/geolocator ];then if [ -f /etc/config/geolocator ];then
SCRIPT_NIN_QUALITY=`uci get geolocator.@script[0].min_quality` SCRIPT_NIN_QUALITY=`uci get geolocator.@script[0].min_quality`
SCRIPT_NUM_LENGTH=`uci get geolocator.@script[0].geo_num_length`
SCRIPT_IMPROBABILITY=`uci get geolocator.@script[0].improbability` SCRIPT_IMPROBABILITY=`uci get geolocator.@script[0].improbability`
SCRIPT_MOBILE=`uci get geolocator.@script[0].mobile`
SCRIPT_PIDPART=`uci get geolocator.@script[0].pidpart`
else else
. `dirname $0`/geolocator_config . `dirname $0`/geolocator_config
fi fi
if [ -f $SCRIPT_PIDPART ]; then
echo "The geolocator is still running"
exit 0
else
touch $SCRIPT_PIDPART
fi
Clean_pid() {
if [ -f $SCRIPT_PIDPART ]; then
rm $SCRIPT_PIDPART
fi
exit 0
}
Get_geolocation_info() { Get_geolocation_info() {
LWTRACE=`lwtrace -t 2> /dev/null` LWTRACE=`lwtrace -t 2> /dev/null`
echo $LWTRACE | grep "Scan completed : Your location:" >> /dev/null echo $LWTRACE | grep "Scan completed : Your location:" >> /dev/null
...@@ -33,52 +50,61 @@ Get_geolocation_info() { ...@@ -33,52 +50,61 @@ Get_geolocation_info() {
fi fi
} }
Ceck_geocoordinate() { #Ceck_geocoordinate() {
if echo $1 | grep -E "^[+-]?[0-9]+(\.[0-9]+)?$" >> /dev/null # if echo $1 | grep -E "^[+-]?[0-9]+(\.[0-9]+)?$" >> /dev/null
then # then
if echo $1 | grep "$SCRIPT_IMPROBABILITY" >> /dev/null # if echo $1 | grep -v -E "^[0-9]+(\.[0-9]*(0{3}|1{3}|2{3}|3{3}|4{3}|5{3}|6{3}|7{3}|8{3}|9{3})[0-9]*)?$" >> /dev/null
then # then
return 1 # return 1
fi # fi
else # else
return 1 # return 1
fi # fi
return 0 # return 0
} #}
Get_gluon_share_location() { Get_gluon_share_location() {
# 1 holt sich eine neue Position 0 nicht
SHARE_LOCATION=`uci get gluon-node-info.@location[0].share_location` SHARE_LOCATION=`uci get gluon-node-info.@location[0].share_location`
GLUON_LAT=`uci get gluon-node-info.@location[0].latitude`
GLUON_LON=`uci get gluon-node-info.@location[0].longitude`
if [ $SHARE_LOCATION -eq 1 ]; then if [ $SHARE_LOCATION -eq 1 ]; then
Ceck_geocoordinate $GLUON_LAT echo "Schare location 1"
if [ $? -eq 1 ]; then GLUON_LAT=`uci get gluon-node-info.@location[0].latitude`
return 1 GLUON_LON=`uci get gluon-node-info.@location[0].longitude`
fi # 1. Prüfe auf reine zahlen && die zahlenlänge
Ceck_geocoordinate $GLUON_LON if echo $GLUON_LAT | grep -E "^[0-9]+(\.[0-9]+)?$" >> /dev/null
if [ $? -eq 1 ]; then then
return 1 echo "Es sind nur zahlen"
if ! [ ${#GLUON_LAT} < $SCRIPT_NUM_LENGTH ]; then
echo "geo ist größer als mindes geo"
# 2. Prüfe warscheinlichkeit
if echo $GLUON_LAT | grep -E "^[0-9]+(\.[0-9]*(0{${SCRIPT_IMPROBABILITY}}|1{${SCRIPT_IMPROBABILITY}}|2{${SCRIPT_IMPROBABILITY}}|3{${SCRIPT_IMPROBABILITY}}|4{${SCRIPT_IMPROBABILITY}}|5{${SCRIPT_IMPROBABILITY}}|6{${SCRIPT_IMPROBABILITY}}|7{${SCRIPT_IMPROBABILITY}}|8{${SCRIPT_IMPROBABILITY}}|9{${SCRIPT_IMPROBABILITY}})[0-9]*)?$" >> /dev/null
then
echo "es sind keine x gleichen zahlen beinhaltend"
return 0
fi
fi
fi fi
else # Ceck_geocoordinate $GLUON_LAT
return 1
fi fi
return 0 return 1
} }
Get_geolocation_info # Hol sich die geo position durch die Triangulation
if [ $? -eq 0 ]; then #Get_geolocation_info
#if [ $? -eq 0 ]; then
Get_gluon_share_location Get_gluon_share_location
if [ $? -eq 1 ]; then echo $?
echo "location wird geändert" # if [ $? -eq 1 ]; then
else # echo "location wird geändert"
echo "location wird nich geändert" # else
fi # echo "location wird nich geändert"
echo $LAT # fi
echo $LON # echo $LAT
echo $QUALITY # echo $LON
echo "----------" # echo $QUALITY
else # echo "----------"
echo "lwtrace doesn't gif a location"; #else
fi; # echo "lwtrace doesn't gif a location";
echo $SCRIPT_NIN_QUALITY #fi;
exit 0 #echo $SCRIPT_NIN_QUALITY
Clean_pid
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