preparing for an installation
moved systemd services to /usr/lib/systemd/system will symlink from templates for easy updates
This commit is contained in:
@@ -145,3 +145,4 @@ BIRDNET_USER=pi
|
||||
## These are just for debugging
|
||||
LAST_RUN=
|
||||
THIS_RUN=
|
||||
IDFILE=/home/pi/BirdNET-Pi/IdentifiedSoFar.txt
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# testing getting images dynamically
|
||||
first_call=$(lynx -nonumbers -dump -listonly "https://commons.wikimedia.org/w/index.php?search=${1//_/+}&title=Special:MediaSearch&go=Go&type=image" | sed '11q;d')
|
||||
|
||||
lynx -dump -nonumbers "$(lynx -dump $first_call \
|
||||
| awk '/CiteThisPage/ {print $2}')" \
|
||||
| grep -A10 'Chicago style' \
|
||||
| grep -A10 -e '^$' \
|
||||
| grep -B10 'CBE' \
|
||||
| grep -B10 -e '^$'
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# testing getting images dynamically
|
||||
set -x
|
||||
first_call=$(lynx -accept-all-cookies -dump -listonly "https://commons.wikimedia.org/w/index.php?search=${1//_/+}&title=Special:MediaSearch&go=Go&type=image")
|
||||
lynx -dump -listonly -accept-all-cookies\
|
||||
$(echo "$first_call" \
|
||||
| sed '11q;d' \
|
||||
| awk '{print $2}' ) \
|
||||
| awk '/thumb/ {print $2}' \
|
||||
| head -1 \
|
||||
| xargs echo -n
|
||||
@@ -159,7 +159,7 @@ BIRDNET_USER=pi
|
||||
## These are just for debugging
|
||||
LAST_RUN=
|
||||
THIS_RUN=
|
||||
|
||||
IDFILE=/home/pi/BirdNET-Pi/IdentifiedSoFar.txt
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
+12
-18
@@ -16,7 +16,7 @@ install_depends() {
|
||||
| sudo -E bash
|
||||
apt -qqq update && apt -qqy upgrade
|
||||
echo "icecast2 icecast2/icecast-setup boolean false" | debconf-set-selections
|
||||
apt install -qqy caddy lynx ftpd sqlite3 php-sqlite3 alsa-utils \
|
||||
apt install -qqy caddy ftpd sqlite3 php-sqlite3 alsa-utils \
|
||||
pulseaudio avahi-utils sox libsox-fmt-mp3 php php-fpm php-curl php-xml \
|
||||
php-zip icecast2 swig ffmpeg wget unzip curl cmake make bc libjpeg-dev \
|
||||
zlib1g-dev python3-dev python3-pip python3-venv
|
||||
@@ -37,11 +37,10 @@ update_etc_hosts() {
|
||||
|
||||
install_scripts() {
|
||||
ln -sf ${my_dir}/* /usr/local/bin/
|
||||
rm /usr/local/bin/index.html
|
||||
}
|
||||
|
||||
install_birdnet_analysis() {
|
||||
cat << EOF > /etc/systemd/system/birdnet_analysis.service
|
||||
cat << EOF > /usr/lib/systemd/system/birdnet_analysis.service
|
||||
[Unit]
|
||||
Description=BirdNET Analysis
|
||||
After=birdnet_server.service
|
||||
@@ -59,7 +58,7 @@ EOF
|
||||
}
|
||||
|
||||
install_birdnet_server() {
|
||||
cat << EOF > /etc/systemd/system/birdnet_server.service
|
||||
cat << EOF > /usr/lib/systemd/system/birdnet_server.service
|
||||
[Unit]
|
||||
Description=BirdNET Analysis Server
|
||||
Before=birdnet_analysis.service
|
||||
@@ -76,7 +75,7 @@ EOF
|
||||
}
|
||||
|
||||
install_extraction_service() {
|
||||
cat << EOF > /etc/systemd/system/extraction.service
|
||||
cat << EOF > /usr/lib/systemd/system/extraction.service
|
||||
[Unit]
|
||||
Description=BirdNET BirdSound Extraction
|
||||
[Service]
|
||||
@@ -92,7 +91,7 @@ EOF
|
||||
}
|
||||
|
||||
install_pushed_notifications() {
|
||||
cat << EOF > /etc/systemd/system/pushed_notifications.service
|
||||
cat << EOF > /usr/lib/systemd/system/pushed_notifications.service
|
||||
[Unit]
|
||||
Description=BirdNET-Pi Pushed.co Notifications
|
||||
[Service]
|
||||
@@ -118,14 +117,12 @@ create_necessary_dirs() {
|
||||
if [ ! -z ${BIRDNETLOG_URL} ];then
|
||||
BIRDNETLOG_URL="$(echo ${BIRDNETLOG_URL} | sed 's/\/\//\\\/\\\//g')"
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/${BIRDNETLOG_URL}/g" $(dirname ${my_dir})/homepage/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/${BIRDNETLOG_URL}/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/${BIRDNETLOG_URL}/g" $(dirname ${my_dir})/scripts/*.php
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/${BIRDNETLOG_URL}/g" $(dirname ${my_dir})/scripts/*/*.php
|
||||
fi
|
||||
if [ ! -z ${WEBTERMINAL_URL} ];then
|
||||
WEBTERMINAL_URL="$(echo ${WEBTERMINAL_URL} | sed 's/\/\//\\\/\\\//g')"
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/${WEBTERMINAL_URL}/g" $(dirname ${my_dir})/homepage/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/${WEBTERMINAL_URL}/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/${WEBTERMINAL_URL}/g" $(dirname ${my_dir})/scripts/*.php
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/${WEBTERMINAL_URL}/g" $(dirname ${my_dir})/scripts/*/*.php
|
||||
fi
|
||||
@@ -134,18 +131,15 @@ create_necessary_dirs() {
|
||||
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts ${EXTRACTED}
|
||||
if [ -z ${BIRDNETPI_URL} ];then
|
||||
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/homepage/*.html
|
||||
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/scripts/*.php
|
||||
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/scripts/*/*.php
|
||||
else
|
||||
BIRDNETPI_URL="$(echo ${BIRDNETPI_URL} | sed 's/\/\//\\\/\\\//g')"
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/homepage/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/scripts/*.php
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/scripts/*/*.php
|
||||
fi
|
||||
|
||||
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/play.css ${EXTRACTED}
|
||||
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/play.php ${EXTRACTED}
|
||||
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/spectrogram.php ${EXTRACTED}
|
||||
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/overview.php ${EXTRACTED}
|
||||
@@ -188,7 +182,7 @@ EOF
|
||||
|
||||
install_recording_service() {
|
||||
echo "Installing birdnet_recording.service"
|
||||
cat << EOF > /etc/systemd/system/birdnet_recording.service
|
||||
cat << EOF > /usr/lib/systemd/system/birdnet_recording.service
|
||||
[Unit]
|
||||
Description=BirdNET Recording
|
||||
[Service]
|
||||
@@ -281,7 +275,7 @@ EOF
|
||||
}
|
||||
|
||||
install_avahi_aliases() {
|
||||
cat << 'EOF' > /etc/systemd/system/avahi-alias@.service
|
||||
cat << 'EOF' > /usr/lib/systemd/system/avahi-alias@.service
|
||||
[Unit]
|
||||
Description=Publish %I as alias for %H.local via mdns
|
||||
After=network.target network-online.target
|
||||
@@ -298,7 +292,7 @@ systemctl enable avahi-alias@"$(hostname)".local.service
|
||||
}
|
||||
|
||||
install_spectrogram_service() {
|
||||
cat << EOF > /etc/systemd/system/spectrogram_viewer.service
|
||||
cat << EOF > /usr/lib/systemd/system/spectrogram_viewer.service
|
||||
[Unit]
|
||||
Description=BirdNET-Pi Spectrogram Viewer
|
||||
[Service]
|
||||
@@ -315,7 +309,7 @@ EOF
|
||||
|
||||
install_chart_viewer_service() {
|
||||
echo "Installing the chart_viewer.service"
|
||||
cat << EOF > /etc/systemd/system/chart_viewer.service
|
||||
cat << EOF > /usr/lib/systemd/system/chart_viewer.service
|
||||
[Unit]
|
||||
Description=BirdNET-Pi Chart Viewer Service
|
||||
[Service]
|
||||
@@ -335,7 +329,7 @@ install_gotty_logs() {
|
||||
${HOME}/.gotty
|
||||
sudo -u ${USER} ln -sf $(dirname ${my_dir})/templates/bashrc \
|
||||
${HOME}/.bashrc
|
||||
cat << EOF > /etc/systemd/system/birdnet_log.service
|
||||
cat << EOF > /usr/lib/systemd/system/birdnet_log.service
|
||||
[Unit]
|
||||
Description=BirdNET Analysis Log
|
||||
[Service]
|
||||
@@ -349,7 +343,7 @@ ExecStart=/usr/local/bin/gotty -p 8080 --title-format "BirdNET-Pi Log" birdnet_l
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl enable birdnet_log.service
|
||||
cat << EOF > /etc/systemd/system/web_terminal.service
|
||||
cat << EOF > /usr/lib/systemd/system/web_terminal.service
|
||||
[Unit]
|
||||
Description=BirdNET-Pi Web Terminal
|
||||
[Service]
|
||||
@@ -394,7 +388,7 @@ config_icecast() {
|
||||
}
|
||||
|
||||
install_livestream_service() {
|
||||
cat << EOF > /etc/systemd/system/livestream.service
|
||||
cat << EOF > /usr/lib/systemd/system/livestream.service
|
||||
[Unit]
|
||||
Description=BirdNET-Pi Live Stream
|
||||
After=network-online.target
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Update the species list
|
||||
#set -x
|
||||
trap 'rm -f "$TMPFILE"' EXIT
|
||||
source /etc/birdnet/birdnet.conf
|
||||
db=birds
|
||||
dbuser=birder
|
||||
dbpassword=${DB_PWD}
|
||||
|
||||
mysql -u${dbuser} -p${dbpassword} ${db} \
|
||||
-e 'SELECT Com_Name
|
||||
FROM detections
|
||||
GROUP BY Com_Name' |\
|
||||
tail -n+2 > ${IDFILE}
|
||||
sqlite3 /home/pi/BirdNET-Pi/scripts/birds.db "SELECT DISTINCT(Com_Name) FROM detections" | sort > ${IDFILE}
|
||||
|
||||
Reference in New Issue
Block a user