A live bird collage card for your Home Assistant dashboard.
add auto update support to update script
frederikaf5c8ddf9df5
diff --git a/scripts/update_birdnet.sh b/scripts/update_birdnet.shindex 1df55765..62cbee36 100755--- a/scripts/update_birdnet.sh+++ b/scripts/update_birdnet.sh@@ -3,7 +3,7 @@source /etc/birdnet/birdnet.conftrap 'exit 1' SIGINT SIGHUP-usage() { echo "Usage: $0 [-r <remote name>] [-b <branch name>]" 1>&2; exit 1; }+usage() { echo "Usage: $0 [-r <remote name>] [-b <branch name>] [-a]" 1>&2; exit 1; }if [ -n "${BIRDNET_USER}" ]; thenUSER=${BIRDNET_USER}@@ -17,8 +17,9 @@ my_dir=$HOME/BirdNET-Pi/scripts# Defaultsremote="origin"branch="main"+auto_update=""-while getopts ":r:b:" o; do+while getopts ":r:b:a" o; docase "${o}" inr)remote=${OPTARG}@@ -33,6 +34,9 @@ while getopts ":r:b:" o; dob)branch=${OPTARG};;+ a)+ auto_update=1+ ;;*)usage;;@@ -46,6 +50,21 @@ sudo_with_user () {set +x}+can_auto_update () {+ if [ -z ${AUTOMATIC_UPDATE} ] || [ "${AUTOMATIC_UPDATE}" == 0 ]; then+ echo "Auto update is not enabled"+ exit 0+ fi+ sudo_with_user git -C $HOME/BirdNET-Pi fetch $remote $branch+ behind_count=$(sudo_with_user git -C $HOME/BirdNET-Pi rev-list --count HEAD..@{u})+ if [ "${behind_count}" -eq 0 ]; then+ echo "No updates"+ exit 0+ fi+}++[ -n "${auto_update}" ] && can_auto_update+# Get current HEAD hashcommit_hash=$(sudo_with_user git -C $HOME/BirdNET-Pi rev-parse HEAD)