# my_IPCity # Fonction pour récupérer la géolocalisation à partir de l'adresse IP

This commit is contained in:
fred 2024-02-25 18:30:04 +01:00
parent 8fb5a09f86
commit c921b12b87
2 changed files with 36 additions and 0 deletions

View File

@ -102,8 +102,13 @@ if [[ ${QRCODE} == "station" ]]; then
ISTATION=$(cat ~/.zen/tmp/ISTATION)
fi
## FIND STATION GPS CLOSEST ACTIVE KEY
source ~/.zen/GPS
## SHOW ZenStation FRONT
sed "s~_STATION_~${myIPFS}${ISTATION}/~g" $MY_PATH/../templates/ZenStation/index.html > ~/.zen/tmp/${MOATS}/index.htm
sed -i "s~2L8vaYixCf97DMT8SistvQFeBj7vb6RQL7tvwyiv1XVH~${WORLDG1PUB}~g" ~/.zen/tmp/${MOATS}/index.htm
sed -i "s~http://127.0.0.1:8080~${myIPFS}~g" ~/.zen/tmp/${MOATS}/index.htm
sed -i "s~http://127.0.0.1:33101~${myG1BILLET}~g" ~/.zen/tmp/${MOATS}/index.htm
sed -i "s~http://astroport.localhost:1234~${myASTROPORT}~g" ~/.zen/tmp/${MOATS}/index.htm

View File

@ -428,6 +428,37 @@ function makecoord() {
echo "${input}"
}
# Fonction pour récupérer la météo depuis l'API OpenWeatherMap
recuperer_meteo() {
echo "En train de récupérer les données météo..."
# Récupérer la météo à l'aide de l'API OpenWeatherMap
ville="Paris" # Vous pouvez modifier la ville ici
api_key="310103dee4a9d1b716ee27d79f162c7e" # Remplacez YOUR_API_KEY par votre clé API OpenWeatherMap
url="http://api.openweathermap.org/data/2.5/weather?q=$ville&appid=$api_key&units=metric"
meteo=$(curl -s $url)
# Extraire les informations pertinentes de la réponse JSON
temperature=$(echo $meteo | jq -r '.main.temp')
description=$(echo $meteo | jq -r '.weather[0].description')
echo "La météo à $ville : $description, Température: $temperature °C"
}
# my_IPCity # Fonction pour récupérer la géolocalisation à partir de l'adresse IP
my_IPCity() {
local ip=$1
if [ -z "$ip" ]; then
ip=$(curl 'https://api.ipify.org?format=json' --silent | jq -r '.ip')
fi
local url="http://ip-api.com/json/$ip"
local geolocalisation=$(curl -s "$url")
local ville=$(echo "$geolocalisation" | jq -r '.city')
local pays=$(echo "$geolocalisation" | jq -r '.country')
echo "$ville, $pays"
}
IPFSNODEID="$(myIpfsPeerId)"
[[ ! $MOATS ]] && MOATS="$(myDate)"
isLAN="$(isLan)"