Allow restarts

This commit is contained in:
Alexandre
2025-03-04 22:57:01 +01:00
parent d25c7eb600
commit cc6458b132
10 changed files with 120 additions and 25 deletions

View File

@@ -2,7 +2,10 @@
# shellcheck shell=bash # shellcheck shell=bash
set -e set -e
# Save a copy of the script for further restarts ##################
# ALLOW RESTARTS #
##################
if [ -f /etc/cont-init.d/99-run.sh ]; then if [ -f /etc/cont-init.d/99-run.sh ]; then
mkdir -p /etc/scripts-init mkdir -p /etc/scripts-init
sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh

View File

@@ -2,7 +2,10 @@
# shellcheck shell=bash # shellcheck shell=bash
set -e set -e
# Save a copy of the script for further restarts ##################
# ALLOW RESTARTS #
##################
if [ -f /etc/cont-init.d/99-run.sh ]; then if [ -f /etc/cont-init.d/99-run.sh ]; then
mkdir -p /etc/scripts-init mkdir -p /etc/scripts-init
sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh
@@ -10,6 +13,10 @@ if [ -f /etc/cont-init.d/99-run.sh ]; then
cp /etc/cont-init.d/99-run.sh /etc/scripts-init/ cp /etc/cont-init.d/99-run.sh /etc/scripts-init/
fi fi
######################
# RESTORE STREAMDATA #
######################
if [ -d /config/TemporaryFiles ]; then if [ -d /config/TemporaryFiles ]; then
# Check if there are .wav files in /config/TemporaryFiles # Check if there are .wav files in /config/TemporaryFiles

View File

@@ -2,7 +2,10 @@
# shellcheck shell=bash # shellcheck shell=bash
set -e set -e
# Save a copy of the script for further restarts ##################
# ALLOW RESTARTS #
##################
if [ -f /etc/cont-init.d/99-run.sh ]; then if [ -f /etc/cont-init.d/99-run.sh ]; then
mkdir -p /etc/scripts-init mkdir -p /etc/scripts-init
sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh

View File

@@ -2,7 +2,10 @@
# shellcheck shell=bash # shellcheck shell=bash
set -e set -e
# Save a copy of the script for further restarts ##################
# ALLOW RESTARTS #
##################
if [ -f /etc/cont-init.d/99-run.sh ]; then if [ -f /etc/cont-init.d/99-run.sh ]; then
mkdir -p /etc/scripts-init mkdir -p /etc/scripts-init
sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh
@@ -10,6 +13,10 @@ if [ -f /etc/cont-init.d/99-run.sh ]; then
cp /etc/cont-init.d/99-run.sh /etc/scripts-init/ cp /etc/cont-init.d/99-run.sh /etc/scripts-init/
fi fi
############
# SET MQTT #
############
# Function to perform common setup steps # Function to perform common setup steps
common_steps () { common_steps () {
# Attempt to connect to the MQTT broker # Attempt to connect to the MQTT broker

View File

@@ -2,6 +2,17 @@
# shellcheck shell=bash # shellcheck shell=bash
set -e set -e
##################
# ALLOW RESTARTS #
##################
if [ -f /etc/cont-init.d/99-run.sh ]; then
mkdir -p /etc/scripts-init
sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh
sed -i "/ rm/d" /ha_entrypoint.sh
cp /etc/cont-init.d/99-run.sh /etc/scripts-init/
fi
################ ################
# ADD FEATURES # # ADD FEATURES #
################ ################

View File

@@ -2,6 +2,17 @@
# shellcheck shell=bash # shellcheck shell=bash
set -e set -e
##################
# ALLOW RESTARTS #
##################
if [ -f /etc/cont-init.d/99-run.sh ]; then
mkdir -p /etc/scripts-init
sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh
sed -i "/ rm/d" /ha_entrypoint.sh
cp /etc/cont-init.d/99-run.sh /etc/scripts-init/
fi
################ ################
# MODIFY WEBUI # # MODIFY WEBUI #
################ ################
@@ -14,16 +25,20 @@ sed -i '/>System Controls/d' "$HOME/BirdNET-Pi/homepage/views.php"
# Remove Ram drive option from webui # Remove Ram drive option from webui
echo "... removing Ram drive from webui as it is handled from HA" echo "... removing Ram drive from webui as it is handled from HA"
sed -i '/Ram drive/{n;s/center"/center" style="display: none;"/;}' "$HOME/BirdNET-Pi/scripts/service_controls.php" if grep -q "Ram drive" "$HOME/BirdNET-Pi/scripts/service_controls.php"; then
sed -i '/Ram drive/d' "$HOME/BirdNET-Pi/scripts/service_controls.php" sed -i '/Ram drive/{n;s/center"/center" style="display: none;"/;}' "$HOME/BirdNET-Pi/scripts/service_controls.php"
sed -i '/Ram drive/d' "$HOME/BirdNET-Pi/scripts/service_controls.php"
fi
# Correct services to start as user pi # Correct services to start as user pi
echo "... updating services to start as user pi" echo "... updating services to start as user pi"
while IFS= read -r file; do if ! grep -q "/usr/bin/sudo" "$HOME/BirdNET-Pi/templates/birdnet_log.service"; then
if [[ "$(basename "$file")" != "birdnet_log.service" ]]; then while IFS= read -r file; do
sed -i "s|ExecStart=|ExecStart=/usr/bin/sudo -u pi |g" "$file" if [[ "$(basename "$file")" != "birdnet_log.service" ]]; then
fi sed -i "s|ExecStart=|ExecStart=/usr/bin/sudo -u pi |g" "$file"
done < <(find "$HOME/BirdNET-Pi/templates/" -name "birdnet*.service" -print) fi
done < <(find "$HOME/BirdNET-Pi/templates/" -name "birdnet*.service" -print)
fi
# Send services log to container logs # Send services log to container logs
echo "... redirecting services logs to container logs" echo "... redirecting services logs to container logs"
@@ -52,16 +67,20 @@ sed -i "/PHP_SERVICE=/c PHP_SERVICE=\$(systemctl list-unit-files -t service --no
echo "... modifying Caddyfile configurations" echo "... modifying Caddyfile configurations"
caddy fmt --overwrite /etc/caddy/Caddyfile caddy fmt --overwrite /etc/caddy/Caddyfile
#Change port to leave 80 free for certificate requests #Change port to leave 80 free for certificate requests
sed -i "s|http://|http://:8081|g" /etc/caddy/Caddyfile if ! grep -q "http://:8081" /etc/caddy/Caddyfile; then
sed -i "s|http://|http://:8081|g" "$HOME/BirdNET-Pi/scripts/update_caddyfile.sh" sed -i "s|http://|http://:8081|g" /etc/caddy/Caddyfile
if [ -f /etc/caddy/Caddyfile.original ]; then sed -i "s|http://|http://:8081|g" "$HOME/BirdNET-Pi/scripts/update_caddyfile.sh"
rm /etc/caddy/Caddyfile.original if [ -f /etc/caddy/Caddyfile.original ]; then
rm /etc/caddy/Caddyfile.original
fi
fi fi
# Correct webui paths # Correct webui paths
echo "... correcting webui paths" echo "... correcting webui paths"
sed -i "s|/stats|/stats/|g" "$HOME/BirdNET-Pi/homepage/views.php" if ! grep -q "/stats/" "$HOME/BirdNET-Pi/homepage/views.php"; then
sed -i "s|/log|/log/|g" "$HOME/BirdNET-Pi/homepage/views.php" sed -i "s|/stats|/stats/|g" "$HOME/BirdNET-Pi/homepage/views.php"
sed -i "s|/log|/log/|g" "$HOME/BirdNET-Pi/homepage/views.php"
fi
# Check if port 80 is correctly configured # Check if port 80 is correctly configured
if [ -n "$(bashio::addon.port "80")" ] && [ "$(bashio::addon.port "80")" != 80 ]; then if [ -n "$(bashio::addon.port "80")" ] && [ "$(bashio::addon.port "80")" != 80 ]; then
@@ -70,12 +89,14 @@ fi
# Correct systemctl path # Correct systemctl path
echo "... updating systemctl path" echo "... updating systemctl path"
mv /helpers/systemctl3.py /bin/systemctl if [[ -f /helpers/systemctl3.py ]]; then
chmod a+x /bin/systemctl mv /helpers/systemctl3.py /bin/systemctl
chmod a+x /bin/systemctl
fi
# Improve streamlit cache # Improve streamlit cache
echo "... add streamlit cache" #echo "... add streamlit cache"
sed -i "/def get_data/i \\@st\.cache_resource\(\)" "$HOME/BirdNET-Pi/scripts/plotly_streamlit.py" #sed -i "/def get_data/i \\@st\.cache_resource\(\)" "$HOME/BirdNET-Pi/scripts/plotly_streamlit.py"
# Allow reverse proxy for streamlit # Allow reverse proxy for streamlit
echo "... allow reverse proxy for streamlit" echo "... allow reverse proxy for streamlit"
@@ -88,9 +109,11 @@ sed -i '/sox.*-V1/s/spectrogram/highpass 250 spectrogram/' "$HOME/BirdNET-Pi/scr
# Correct timedatectl path # Correct timedatectl path
echo "updating timedatectl path" echo "updating timedatectl path"
mv /helpers/timedatectl /usr/bin/timedatectl if [[ -f /helpers/timedatectl ]]; then
chown pi:pi /usr/bin/timedatectl mv /helpers/timedatectl /usr/bin/timedatectl
chmod a+x /usr/bin/timedatectl chown pi:pi /usr/bin/timedatectl
chmod a+x /usr/bin/timedatectl
fi
# Correct timezone showing in config.php # Correct timezone showing in config.php
sed -i -e '/<option disabled selected>/s/selected//' \ sed -i -e '/<option disabled selected>/s/selected//' \
@@ -105,4 +128,5 @@ if export "$(grep "^DATABASE_LANG" /config/birdnet.conf)"; then
else else
bashio::log.warning "DATABASE_LANG not found in configuration. Using default labels." bashio::log.warning "DATABASE_LANG not found in configuration. Using default labels."
fi fi
"$HOME/BirdNET-Pi/scripts/install_language_label_nm.sh" -l "${DATABASE_LANG:-}" &>/dev/null || bashio::log.warning "Failed to update language labels" "$HOME/BirdNET-Pi/scripts/install_language_label_nm.sh" -l "${DATABASE_LANG:-}" &>/dev/null || bashio::log.warning "Failed to update language labels"

View File

@@ -2,6 +2,17 @@
# shellcheck shell=bash # shellcheck shell=bash
set -e set -e
##################
# ALLOW RESTARTS #
##################
if [ -f /etc/cont-init.d/99-run.sh ]; then
mkdir -p /etc/scripts-init
sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh
sed -i "/ rm/d" /ha_entrypoint.sh
cp /etc/cont-init.d/99-run.sh /etc/scripts-init/
fi
################# #################
# NGINX SETTING # # NGINX SETTING #
################# #################

View File

@@ -2,6 +2,17 @@
# shellcheck shell=bash # shellcheck shell=bash
set -e set -e
##################
# ALLOW RESTARTS #
##################
if [ -f /etc/cont-init.d/99-run.sh ]; then
mkdir -p /etc/scripts-init
sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh
sed -i "/ rm/d" /ha_entrypoint.sh
cp /etc/cont-init.d/99-run.sh /etc/scripts-init/
fi
############### ###############
# SSL SETTING # # SSL SETTING #
############### ###############

View File

@@ -2,6 +2,21 @@
# shellcheck shell=bash # shellcheck shell=bash
set -e set -e
##################
# ALLOW RESTARTS #
##################
if [ -f /etc/cont-init.d/99-run.sh ]; then
mkdir -p /etc/scripts-init
sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh
sed -i "/ rm/d" /ha_entrypoint.sh
cp /etc/cont-init.d/99-run.sh /etc/scripts-init/
fi
######################
# INSTALL TENSORFLOW #
######################
# Check if the CPU supports AVX2 # Check if the CPU supports AVX2
if [[ "$(uname -m)" = "x86_64" ]]; then if [[ "$(uname -m)" = "x86_64" ]]; then
if lscpu | grep -q "Flags"; then if lscpu | grep -q "Flags"; then

View File

@@ -3,7 +3,10 @@
set -eu set -eu
# Save a copy of the script for further restarts ##################
# ALLOW RESTARTS #
##################
if [ -f /etc/cont-init.d/99-run.sh ]; then if [ -f /etc/cont-init.d/99-run.sh ]; then
mkdir -p /etc/scripts-init mkdir -p /etc/scripts-init
sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh sed -i "s|/etc/cont-init.d|/etc/scripts-init|g" /ha_entrypoint.sh