Nachtzuster / BirdNET-Pi

A realtime acoustic bird classification system for the Raspberry Pi 5, 4B 3B+ 0W2 and more. Built on the TFLite version of BirdNET.
https://birdnetpi.com
Other
133 stars 20 forks source link

Installation breaks when unable to access ip-api.com #100

Closed eekdood closed 3 months ago

eekdood commented 3 months ago

Describe the bug When installing on a clean system, installation fails when unable to contact ip-api.com. I run pi-hole on my network and access to this domain is restricted. When the restriction is removed, installation completes without issue.

To Reproduce Block access to ip-api.com Run installation script

Expected behavior Lines 10-19 of /scripts/install_config.sh has error handling code that is not correctly handling this situation. It looks like the intention is to set Lat and Lon to zeroes.

Screenshots

Additional context

Your build Raspi4 with fresh install of RaspiOS(64) Lite from Official Imager.

Code or log snippets

log or code ``` Cloning into '/home/pi/BirdNET-Pi'... remote: Enumerating objects: 141, done. remote: Counting objects: 100% (141/141), done. remote: Compressing objects: 100% (133/133), done. remote: Total 141 (delta 10), reused 61 (delta 3), pack-reused 0 Receiving objects: 100% (141/141), 108.64 MiB | 4.96 MiB/s, done. Resolving deltas: 100% (10/10), done. Updating files: 100% (129/129), done. + exec +++ date +%F ++ tee -i installation-2024-06-13.txt + set -e + my_dir=/home/pi/BirdNET-Pi + export my_dir=/home/pi/BirdNET-Pi + my_dir=/home/pi/BirdNET-Pi + cd /home/pi/BirdNET-Pi/scripts + git log -n 1 --pretty=oneline --no-color --decorate 0a09e73549c0b0d4f5effbeb7088a0fcf7eb36fa (grafted, HEAD -> main, origin/main, origin/HEAD) fix: this_run was removed, so use get_settings + source install_helpers.sh ++ uname -m + '[' aarch64 '!=' aarch64 ']' + ./install_config.sh + set -e + trap 'exit 1' SIGINT SIGHUP + echo 'Beginning ./install_config.sh' Beginning ./install_config.sh + birdnet_conf=/home/pi/BirdNET-Pi/birdnet.conf ++ curl -s4 http://ip-api.com/json + json= + exit 1 The installation exited unsuccessfully. ```
alexbelgium commented 3 months ago

Hi, seeing that your log shows "json=", the failure could be when jq tries to parse an empty variable. https://github.com/Nachtzuster/BirdNET-Pi/blob/0a09e73549c0b0d4f5effbeb7088a0fcf7eb36fa/scripts/install_config.sh#L12

This should probably solve it : if [ -n "$json" ] && [ "$(echo "$json" | jq -r .status)" = "success" ]; then that way the jq only executes if $json is defiend