From f8aa042a4ba31f00b33cee050469be48aadbad4b Mon Sep 17 00:00:00 2001 From: poka Date: Sat, 9 Sep 2023 22:26:03 +0200 Subject: [PATCH] update geoloc-members-json.sh script --- scripts/geoloc-members-json.sh | 113 +++------------------------------ scripts/walletsBalance.sh | 3 +- 2 files changed, 9 insertions(+), 107 deletions(-) diff --git a/scripts/geoloc-members-json.sh b/scripts/geoloc-members-json.sh index 48eef70..3dcf948 100755 --- a/scripts/geoloc-members-json.sh +++ b/scripts/geoloc-members-json.sh @@ -4,117 +4,20 @@ GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.." [[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env source $GPATH/.env -timeout=320 -startLoop=$(date +%s) -echo "### $(date +%d-%m-%y) ###" +log="/tmp/geoloc-members.log" +echo "### $(date +'%d-%m-%y - %H:%M') ###" >> $log -# Exit if script is already alive -if pidof -o %PPID -x "geoloc-members-json.sh">/dev/null; then - echo "Process already running" - exit 1 -fi +result=$($JAKLIS geolocProfiles) -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 - continue - else - isMbr='"isMember": true,' - userIdFormat="\"userId\": $userId," - resultWithMbr=$(echo "$result" | sed "s/\"geoPoint\": {/$userIdFormat $isMbr \"geoPoint\": {/g") - echo "$resultWithMbr," >> $FILE - fi - [[ $DEBUG ]] && echo "$j - $i" -# [[ $DEBUG && $j -ge 5 ]] && break - ((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 - continue - else - isMbr='"isMember": false,' - userIdFormat="\"userId\": $userId," - resultWithMbr=$(echo "$result" | sed "s/\"geoPoint\": {/$userIdFormat $isMbr \"geoPoint\": {/g") - echo "$resultWithMbr," >> $FILE - fi - [[ $DEBUG ]] && echo "$j - $i" -# [[ $DEBUG && $j -ge 7 ]] && break - ((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 - continue - else - isMbr='"isMember": false,' - resultWithMbr=$(echo "$result" | sed "s/\"geoPoint\": {/$isMbr \"geoPoint\": {/g") - echo "$resultWithMbr," >> $FILE - fi - [[ $DEBUG ]] && echo "$j - $i" -# [[ $DEBUG && $j -ge 10 ]] && break - ((j++)) -done - -nowD=$(date +"%s") - -sed -i '$ d' $FILE -echo "}]," >> $FILE -echo "\"time\": $nowD" >> $FILE -echo "}" >> $FILE - -echo "Parse end result with jq" - -finalResult=$(cat $FILE | sed "/^,/Id" | jq .) +finalResult=$(echo "$result" | jq .) RESULT=$? if [ $RESULT -eq 0 ]; then - echo "$finalResult" > $FINAL_LOCATION + echo "$finalResult" > $WEBPATH/data/geoloc-members.json + echo "OK" >> $log else - echo "Failed" >> $FILE + echo "Failed" >> $log fi -echo "---" +echo "---" >> $log diff --git a/scripts/walletsBalance.sh b/scripts/walletsBalance.sh index dc8f20e..a671ae0 100755 --- a/scripts/walletsBalance.sh +++ b/scripts/walletsBalance.sh @@ -5,8 +5,7 @@ GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.." [[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env source $GPATH/.env -JAKLIS=$(which jaklis) -/usr/local/bin/jaklis listWallets -b > $WEBPATH/data/forbes.json +$JAKLIS listWallets -b > $WEBPATH/data/forbes.json date=$(date -d '+1 minute' +"%d/%m/%Y à %H:%M")