diff --git a/scripts/geoloc-members-json.sh b/scripts/geoloc-members-json.sh index e15ad0d..0c951c1 100755 --- a/scripts/geoloc-members-json.sh +++ b/scripts/geoloc-members-json.sh @@ -4,26 +4,37 @@ GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.." [[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env source $GPATH/.env -timeout=5 +timeout=120 +startLoop=$(date +%s) + +[[ $(ps -aux | grep "[g]eoloc-members") ]] && echo "ERROR: Script is still started... exit." && exit 1 + +echo "### $(date +%d-%m-%y) ###" FILE="/tmp/geoloc-members.json" FINAL_LOCATION="$WEBPATH/data/geoloc-members.json" FINAL_LOCATION_ALT="$WEBPATH/data/geoloc-members-alt.json" +echo "Get wallets list" + DATA_MBR=$($JAKLIS listWallets --brut --mbr) DATA_NONMBR=$($JAKLIS listWallets --brut --non_mbr) DATA_LARF=$($JAKLIS listWallets --brut --larf) echo "{\"wallets\":[" > $FILE +echo "Start loop membres" + oldIFS=$IFS; IFS=$'\n'; j=0 for i in $DATA_MBR; do IFS=$oldIFS + [[ $((`date +%s`-$startLoop)) -ge 72000 ]] && echo "ERROR: spent more than 20h ... exit." && exit 1 pubkey=$(echo $i | awk '{ print $1 }') userId=\"$(echo $i | awk '{ print $2 }')\" result=$(timeout $timeout $JAKLIS get -p $pubkey) + [[ $? -eq 124 ]] && echo "timeout $pubkey..." && continue geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null) if [[ "$geoPoint" == "null" || "$result" == "Profile vide" ]]; then @@ -39,12 +50,16 @@ for i in $DATA_MBR; do ((j++)) done +echo "Start non membres loop" + IFS=$'\n' for i in $DATA_NONMBR; do IFS=$oldIFS + [[ $((`date +%s`-$startLoop)) -ge 72000 ]] && echo "ERROR: spent more than 20h ... exit." && exit 1 pubkey=$(echo $i | awk '{ print $1 }') userId=\"$(echo $i | awk '{ print $2 }')\" result=$(timeout $timeout $JAKLIS get -p $pubkey) + [[ $? -eq 124 ]] && echo "timeout $pubkey..." && continue geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null) if [[ "$geoPoint" == "null" || "$result" == "Profile vide" ]]; then @@ -60,9 +75,12 @@ for i in $DATA_NONMBR; do ((j++)) done +echo "Start larfeuil loop" for i in $DATA_LARF; do + [[ $((`date +%s`-$startLoop)) -ge 72000 ]] && echo "ERROR: spent more than 20h ... exit." && exit 1 result=$(timeout $timeout $JAKLIS get -p $i) + [[ $? -eq 124 ]] && echo "timeout $i" && continue geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null) if [[ "$geoPoint" == "null" || "$result" == "Profile vide" ]]; then @@ -84,6 +102,8 @@ echo "}]," >> $FILE echo "\"time\": $nowD" >> $FILE echo "}" >> $FILE +echo "Parse end result with jq" + finalResult=$(cat $FILE | jq .) RESULT=$? @@ -92,3 +112,5 @@ if [ $RESULT -eq 0 ]; then else echo "Failed" >> $FILE fi + +echo "---"