fix: do not clobber the link

This commit is contained in:
frederik
2025-01-25 14:30:40 +01:00
parent 05268f19bd
commit 0ed3fbb47a
+8 -2
View File
@@ -63,10 +63,16 @@ ensure_python_package() {
fi fi
} }
# sed -i on /etc/birdnet/birdnet.conf overwites the symbolic link - restore the link
if ! [ -L /etc/birdnet/birdnet.conf ] ; then
sudo_with_user cp -f /etc/birdnet/birdnet.conf $HOME/BirdNET-Pi/
ln -fs $HOME/BirdNET-Pi/birdnet.conf /etc/birdnet/birdnet.conf
fi
# update snippets below # update snippets below
SRC="APPRISE_NOTIFICATION_BODY='(.*)'$" SRC="APPRISE_NOTIFICATION_BODY='(.*)'$"
DST='APPRISE_NOTIFICATION_BODY="\1"' DST='APPRISE_NOTIFICATION_BODY="\1"'
sed -i -E "s/$SRC/$DST/" /etc/birdnet/birdnet.conf sed -i --follow-symlinks -E "s/$SRC/$DST/" /etc/birdnet/birdnet.conf
if ! grep -E '^DATA_MODEL_VERSION=' /etc/birdnet/birdnet.conf &>/dev/null;then if ! grep -E '^DATA_MODEL_VERSION=' /etc/birdnet/birdnet.conf &>/dev/null;then
echo "DATA_MODEL_VERSION=1" >> /etc/birdnet/birdnet.conf echo "DATA_MODEL_VERSION=1" >> /etc/birdnet/birdnet.conf
@@ -84,7 +90,7 @@ fi
SRC='^APPRISE_NOTIFICATION_BODY="A \$comname \(\$sciname\) was just detected with a confidence of \$confidence"$' SRC='^APPRISE_NOTIFICATION_BODY="A \$comname \(\$sciname\) was just detected with a confidence of \$confidence"$'
DST='APPRISE_NOTIFICATION_BODY="A \$comname (\$sciname) was just detected with a confidence of \$confidence (\$reason)"' DST='APPRISE_NOTIFICATION_BODY="A \$comname (\$sciname) was just detected with a confidence of \$confidence (\$reason)"'
sed -i -E "s/$SRC/$DST/" /etc/birdnet/birdnet.conf sed -i --follow-symlinks -E "s/$SRC/$DST/" /etc/birdnet/birdnet.conf
if ! grep -E '^INFO_SITE=' /etc/birdnet/birdnet.conf &>/dev/null;then if ! grep -E '^INFO_SITE=' /etc/birdnet/birdnet.conf &>/dev/null;then
echo "INFO_SITE=\"ALLABOUTBIRDS\"" >> /etc/birdnet/birdnet.conf echo "INFO_SITE=\"ALLABOUTBIRDS\"" >> /etc/birdnet/birdnet.conf