Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions scripts/install_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,28 @@ EOF
systemctl enable chart_viewer.service
}

install_bashrc() {
if [[ -L ${HOME}/.bashrc ]]; then
sudo -u ${USER} rm ${HOME}/.bashrc
fi

if [ ! -f ${HOME}/.bashrc ]; then
sudo -u ${USER} cp ${HOME}/BirdNET-Pi/templates/bashrc ${HOME}/.bashrc
else
if ! grep -q "source ~/.birdnet_bashrc" ${HOME}/.bashrc; then
echo "# custom sourcing for BirdNET, please don't remove" >> ${HOME}/.bashrc
echo "source ~/.birdnet_bashrc" >> ${HOME}/.bashrc
fi
fi

if [ ! -f ${HOME}/.birdnet_bashrc ]; then
sudo -u ${USER} ln -sf ${HOME}/BirdNET-Pi/templates/birdnet_bashrc ${HOME}/.birdnet_bashrc
fi
}

install_gotty_logs() {
sudo -u ${USER} ln -sf $my_dir/templates/gotty \
${HOME}/.gotty
sudo -u ${USER} ln -sf $my_dir/templates/bashrc \
${HOME}/.bashrc
cat << EOF > $HOME/BirdNET-Pi/templates/birdnet_log.service
[Unit]
Description=BirdNET Analysis Log
Expand Down Expand Up @@ -418,6 +435,7 @@ install_services() {
install_custom_recording_service # But does not enable
install_spectrogram_service
install_chart_viewer_service
install_bashrc
install_gotty_logs
install_phpsysinfo
install_livestream_service
Expand Down
3 changes: 3 additions & 0 deletions scripts/update_birdnet_snippets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ else
fi
my_dir=$HOME/BirdNET-Pi/scripts
source "$my_dir/install_helpers.sh"
source "$my_dir/install_services.sh"

# Sets proper permissions and ownership
find $HOME/Bird* -type f ! -perm -g+wr -exec chmod g+wr {} + 2>/dev/null
Expand Down Expand Up @@ -245,6 +246,8 @@ if [ -L /usr/local/bin/birdnet_analysis.sh ];then
rm -f /usr/local/bin/birdnet_analysis.sh
fi

install_bashrc

# Clean state and update cron if all scripts are not installed
if [ "$(grep -o "#birdnet" /etc/crontab | wc -l)" -lt 6 ]; then
sudo sed -i '/birdnet/,+1d' /etc/crontab
Expand Down
9 changes: 5 additions & 4 deletions templates/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ if ! shopt -oq posix; then
. /etc/bash_completion
fi
fi

# BirdNET default features that users can remove
cd ~/BirdNET-Pi
function remove() {
source /etc/birdnet/birdnet.conf
find $EXTRACTED -iname *${1}* -exec rm -drfv {} +
}
alias rerc="source ~/.bashrc"
alias vimrc="vim ~/.bashrc"

# custom sourcing for BirdNET, please don't remove
source ~/.birdnet_bashrc
10 changes: 10 additions & 0 deletions templates/birdnet_bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# BirdNET-Pi custom bashrc sourcing
# DO NOT MODIFY THIS FILE

function remove() {
source /etc/birdnet/birdnet.conf
find $EXTRACTED -iname *${1}* -exec rm -drfv {} +
}