preparing for an installation
moved systemd services to /usr/lib/systemd/system will symlink from templates for easy updates
This commit is contained in:
@@ -1,59 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# Update BirdNET-Pi
|
||||
source /etc/birdnet/birdnet.conf
|
||||
trap 'rm -f ${tmpfile}' EXIT
|
||||
trap 'exit 1' SIGINT SIGHUP
|
||||
USER=pi
|
||||
HOME=/home/pi
|
||||
my_dir=${HOME}/BirdNET-Pi/scripts
|
||||
tmpfile=$(mktemp)
|
||||
|
||||
services=$(awk '/service/ && /systemctl/ && !/php/ {print $3}' ${my_dir}/install_services.sh | sort)
|
||||
|
||||
remove_services() {
|
||||
for i in "${services[@]}"; do
|
||||
if [ -L /etc/systemd/system/multi-user.target.wants/"${i}" ];then
|
||||
sudo systemctl kill "${i}"
|
||||
sudo systemctl disable "${i}"
|
||||
fi
|
||||
if [ -f /etc/systemd/system/"${i}" ];then
|
||||
sudo rm /etc/systemd/system/"${i}"
|
||||
fi
|
||||
if [ -d /etc/systemd/system/"${i}" ];then
|
||||
sudo rm -drf /etc/systemd/system/"${i}"
|
||||
fi
|
||||
done
|
||||
remove_icecast
|
||||
remove_crons
|
||||
}
|
||||
|
||||
remove_crons() {
|
||||
sudo sed -i '/birdnet/,+1d' /etc/crontab
|
||||
}
|
||||
|
||||
remove_icecast() {
|
||||
if [ -f /etc/init.d/icecast2 ];then
|
||||
sudo /etc/init.d/icecast2 stop
|
||||
sudo systemctl disable --now icecast2
|
||||
fi
|
||||
}
|
||||
|
||||
remove_scripts() {
|
||||
for i in "${scripts[@]}";do
|
||||
if [ -L "/usr/local/bin/${i}" ];then
|
||||
sudo rm -v "/usr/local/bin/${i}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Stage 1 removes old stuff
|
||||
remove_services
|
||||
remove_scripts
|
||||
|
||||
# Backup labels.txt
|
||||
sudo -u${USER} cp -f ~/BirdNET-Pi/model/labels.txt{,.bak}
|
||||
# Stage 2 does a git pull to fetch new things
|
||||
sudo -u${USER} git -C ${HOME}/BirdNET-Pi checkout -f
|
||||
sudo -u${USER} git -C ${HOME}/BirdNET-Pi pull -f
|
||||
# Trigger the new update_birdnet2.sh
|
||||
sudo -u${USER} ${my_dir}/update_birdnet2.sh
|
||||
sudo -u${USER} git -C /home/pi/BirdNET-Pi stash
|
||||
sudo -u${USER} git -C /home/pi/BirdNET-Pi pull
|
||||
sudo systemctl daemon-reload
|
||||
sudo -u${USER} git -C /home/pi/BirdNET-Pi stash pop
|
||||
|
||||
Reference in New Issue
Block a user