62 lines
1.8 KiB
Bash
Executable File
62 lines
1.8 KiB
Bash
Executable File
#!/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/geoloc-members.json"
|
|
|
|
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,'
|
|
userId=$(jaklis id -p $i | jq .idty.username)
|
|
userIdFormat="\"userId\": $userId,"
|
|
resultWithMbr=$(echo "$result" | sed "s/\"geoPoint\": {/$userIdFormat $isMbr \"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 "$result" | sed "s/\"geoPoint\": {/$isMbr \"geoPoint\": {/g")
|
|
echo "$resultWithMbr," >> $FILE
|
|
fi
|
|
done
|
|
|
|
sed -i '$ d' $FILE
|
|
echo "}" >> $FILE
|
|
echo "]" >> $FILE
|
|
|
|
[[ -f $FINAL_LOCATION ]] && cat $FILE | jq . > $FINAL_LOCATION
|
|
|
|
|