Skip to content
This repository was archived by the owner on Aug 17, 2025. It is now read-only.

Commit fcdc99e

Browse files
authored
Merge pull request #992 from srd424/upst-latlong-fix
Fix GeoIP data validation
2 parents 750409d + 9aeee82 commit fcdc99e

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

scripts/install_config.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ echo "Beginning $0"
88
birdnet_conf=$my_dir/birdnet.conf
99

1010
# Retrieve latitude and longitude from web
11-
LATITUDE=$(curl -s4 http://ip-api.com/json?fields=lat,lon | jq .lat)
12-
LONGITUDE=$(curl -s4 http://ip-api.com/json?fields=lat,lon | jq .lon)
13-
14-
# Define regular expression pattern
15-
pattern='^[+-]?[0-9]{2}\.[0-9]{4}$'
16-
17-
# Check if latitude and longitude match the pattern
18-
if ! [[ $LATITUDE =~ $pattern ]] || ! [[ $LONGITUDE =~ $pattern ]]; then
11+
json=$(curl -s4 http://ip-api.com/json)
12+
if [ "$(echo "$json" | jq -r .status)" = "success" ]; then
13+
LATITUDE=$(echo "$json" | jq .lat)
14+
LONGITUDE=$(echo "$json" | jq .lon)
15+
else
1916
echo -e "\033[33mCouldn't set latitude and longitude automatically, you will need to do this manually from the web interface by navigating to Tools -> Settings -> Location.\033[0m"
2017
LATITUDE=0.0000
2118
LONGITUDE=0.0000

0 commit comments

Comments
 (0)