Clean birdnet-pi

This commit is contained in:
Alexandre
2024-04-26 21:26:47 +00:00
parent d680605c91
commit 55a9a22c1f
99 changed files with 104 additions and 735 deletions

View File

@@ -0,0 +1,22 @@
%%interface%%:%%port%% {
reverse_proxy http://localhost:8080 {
header_up Host {host}
header_up X-Forwarded-For {remote}
header_up Connection "upgrade"
header_up Accept-Encoding ""
@base_url {
path /
file {
try_files {path} /%%ingress_entry%%
}
}
handle @base_url {
sub_filter_once off
sub_filter_types *
sub_filter href=\"/ href=\"%%ingress_entry%%/
sub_filter src=\"/ src=\"%%ingress_entry%%/
sub_filter hx-get=\"/ hx-get=\"%%ingress_entry%%/
sub_filter action=\"/ action=\"%%ingress_entry%%/
}
}
}

View File

@@ -1,15 +0,0 @@
#!/usr/bin/with-contenv bashio
# Waiting for dbus
until [[ -e /var/run/dbus/system_bus_socket ]]; do
sleep 1s
done
echo "Starting service: pulseaudio"
while :
do
if [[ ! $(/usr/bin/pulseaudio --check) ]]; then
exec \
s6-setuidgid "$USER" /usr/bin/pulseaudio --start
fi
sleep 10
done

View File

@@ -1,4 +0,0 @@
#!/usr/bin/with-contenv bashio
echo "Starting service: birdnet analysis"
exec \
s6-setuidgid "$USER" "$PYTHON_VIRTUAL_ENV" /usr/local/bin/birdnet_analysis.py

View File

@@ -1,4 +0,0 @@
#!/usr/bin/with-contenv bashio
echo "Starting service: birdnet log"
exec \
s6-setuidgid "$USER" /usr/local/bin/gotty --address localhost -p 8080 --path log --title-format "BirdNET-Pi Log" birdnet_log.sh

View File

@@ -1,4 +0,0 @@
#!/usr/bin/with-contenv bashio
echo "Starting service: birdnet stats"
exec \
s6-setuidgid "$USER" "$HOME"/BirdNET-Pi/birdnet/bin/streamlit run "$HOME"/BirdNET-Pi/scripts/plotly_streamlit.py --browser.gatherUsageStats false --server.address localhost --server.baseUrlPath "/stats"

View File

@@ -1,4 +0,0 @@
#!/usr/bin/with-contenv bashio
echo "Starting service: chart viewer"
exec \
s6-setuidgid "$USER" "$PYTHON_VIRTUAL_ENV" /usr/local/bin/daily_plot.py --daemon --sleep 2

View File

@@ -1,9 +0,0 @@
#!/usr/bin/with-contenv bashio
echo "Starting service: getty"
until [[ -e /var/run/dbus/system_bus_socket ]]; do
sleep 1s
done
exec \
s6-setuidgid "$USER" /sbin/agetty --autologin "${USER}"
--noclear %I "$TERM"

View File

@@ -1,4 +0,0 @@
#!/usr/bin/with-contenv bashio
echo "Starting service: spectrogram viewer"
exec \
s6-setuidgid "$USER" /usr/local/bin/spectrogram.sh

View File

@@ -1,4 +0,0 @@
#!/usr/bin/with-contenv bashio
echo "Starting service: web terminal"
exec \
s6-setuidgid "$USER" /usr/local/bin/gotty --address localhost -w -p 8888 --path terminal --title-format "BirdNET-Pi Terminal" login

View File

@@ -1,8 +1,9 @@
#!/usr/bin/with-contenv bashio
# Dependencies
sockfile="$(find /run/php -name *.sock)"
sockfile="empty"
until [[ -e /var/run/dbus/system_bus_socket ]] && [[ -e "$sockfile" ]]; do
sleep 1s
sockfile="$(find /run/php -name *.sock)"
done
# Correct fpm.sock

View File

@@ -1,9 +0,0 @@
#!/usr/bin/with-contenv bashio
echo "Starting service: birdnet recording"
until [[ -e /start ]]; do
sleep 1s
done
exec \
s6-setuidgid "$USER" /usr/local/bin/birdnet_recording.sh

View File

@@ -1,8 +0,0 @@
#!/usr/bin/with-contenv bashio
echo "Starting service: livestream"
until [[ -e /start ]]; do
sleep 1s
done
exec \
s6-setuidgid "$USER" /usr/local/bin/livestream.sh

View File

@@ -0,0 +1,24 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
set -e
#################
# NGINX SETTING #
#################
declare ingress_interface
declare ingress_port
bashio::log.info "Setting up ingress"
echo "... adding new instructions"
cat /Caddyfile >> /etc/caddy/Caddyfile
rm /Caddyfile
echo "... customizing"
ingress_port=$(bashio::addon.ingress_port)
ingress_interface=$(bashio::addon.ip_address)
ingress_entry=$(bashio::addon.ingress_entry)
sed -i "s/%%port%%/${ingress_port}/g" /etc/caddy/Caddyfile
sed -i "s/%%interface%%/${ingress_interface}/g" /etc/caddy/Caddyfile
sed -i "s|%%ingress_entry%%|${ingress_entry}|g" /etc/caddy/Caddyfile

View File

@@ -7,18 +7,29 @@ set -e
#################
# Starting dbus
echo "Starting service: dbus"
bashio::log.info "Starting system services..."
echo "... dbus"
service dbus start
bashio::log.info "ALSA_CARD option is set to $(bashio::config "ALSA_CARD"). If the microphone doesn't work, please adapt it"
echo " "
# Starting php service
echo "... php"
until [[ -e /var/run/dbus/system_bus_socket ]]; do
sleep 1s
done
systemctl start php*service
########################
# CONFIGURE birdnet-pi #
########################
bashio::log.info "Starting app..."
# Starting avahi service
echo "... avahi"
systemctl start avahi*service
# Restarting all services
bashio::log.info "Ensuring birdnet.conf is in /config ; please customize as needed"
if [ ! -f /config/birdnet.conf ]; then
cp /etc/birdnet/birdnet.conf /config
fi
bashio::log.info "Starting BirdNET-Pi services"
chmod +x $HOME/BirdNET-Pi/scripts/restart_services
/.$HOME/BirdNET-Pi/scripts/restart_services &>/proc/1/fd/1
bashio::log.info "App is accessible from webui"