#!/bin/bash # Récupération du chemin absolut du répertoir du script actuel GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.." [[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env source $GPATH/.env SOURCE_MBR="https://g1-stats.axiom-team.fr/data/wallets-g1-membres.txt" SOURCE_LARF="https://g1-stats.axiom-team.fr/data/wallets-g1-simple.txt" FILE="/tmp/geoloc-members.json" FINAL_LOCATION="$WEBPATH/data" if [[ -f /home/axiom/apps/g1-stats/data/wallets-g1-membres.txt ]]; then DATA_MBR=$(cat /home/axiom/apps/g1-stats/data/wallets-g1-membres.txt) else DATA_MBR=$(curl -s $SOURCE_MBR) fi if [[ -f /home/axiom/apps/g1-stats/data/wallets-g1-simple.txt ]]; then DATA_LARF=$(cat /home/axiom/apps/g1-stats/data/wallets-g1-simple.txt) else DATA_LARF=$(curl -s $SOURCE_LARF) fi echo "[" > $FILE for i in $DATA_MBR; do result=$(jaklis get -p $i) geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null) if [[ "$geoPoint" == "null" || "$result" == "Profile vide" ]]; then continue else isMbr='"isMember": true,' resultWithMbr=$(echo -e "$result" | sed "s/\"geoPoint\": {/$isMbr\n \"geoPoint\": {/g") echo "$resultWithMbr," >> $FILE fi done for i in $DATA_LARF; do result=$(jaklis get -p $i) geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null) if [[ "$geoPoint" == "null" || "$result" == "Profile vide" ]]; then continue else isMbr='"isMember": false,' resultWithMbr=$(echo -e "$result" | sed "s/\"geoPoint\": {/$isMbr\n \"geoPoint\": {/g") echo "$resultWithMbr," >> $FILE fi done sed -i '$ d' $FILE echo "}" >> $FILE echo "]" >> $FILE mv $FILE $FINAL_LOCATION