From a5e4045c1d7d7923a04656005c46b5a998cc4ce5 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 1 May 2024 17:37:33 +0200 Subject: [PATCH] Avoid hardcoding /tmp https://github.com/alexbelgium/hassio-addons/issues/1369#issuecomment-2088623801 --- .../rootfs/etc/cont-finish.d/savestreamdata.sh | 16 ++++++++-------- .../etc/cont-init.d/02-restorestreamdata.sh | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/birdnet-pi/rootfs/etc/cont-finish.d/savestreamdata.sh b/birdnet-pi/rootfs/etc/cont-finish.d/savestreamdata.sh index ab105a2ae..215b7f9fd 100755 --- a/birdnet-pi/rootfs/etc/cont-finish.d/savestreamdata.sh +++ b/birdnet-pi/rootfs/etc/cont-finish.d/savestreamdata.sh @@ -1,18 +1,18 @@ #!/usr/bin/with-contenv bashio # shellcheck shell=bash -if [ -d /tmp/StreamData ]; then +if [ -d "$HOME"/BirdSongs/StreamData ]; then bashio::log.fatal "Container stopping, saving temporary files" - + # Stop the services in parallel - systemctl stop birdnet_analysis & + systemctl stop birdnet_analysis & systemctl stop birdnet_recording - - # Check if there are files in /tmp/StreamData and move them to /data/StreamData + + # Check if there are files in StreamData and move them to /data/StreamData mkdir -p /data/StreamData - if [ "$(ls -A /tmp/StreamData)" ]; then - mv -v /tmp/StreamData/* /data/StreamData/ + if [ "$(ls -A "$HOME"/BirdSongs/StreamData)" ]; then + mv -v "$HOME"/BirdSongs/StreamData/* /data/StreamData/ fi - + bashio::log.fatal "... files safe, allowing container to stop" fi diff --git a/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh b/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh index d0f6f828a..a75881bf2 100755 --- a/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh +++ b/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata.sh @@ -1,20 +1,20 @@ #!/usr/bin/with-contenv bashio # shellcheck shell=bash -# Check if there are files in /tmp/StreamData and move them to /data/StreamData -if [ -d /data/StreamData ] && [ "$(ls -A /tmp/StreamData)" ]; then +# Check if there are files in "$HOME"/BirdSongs/StreamData and move them to /data/StreamData +if [ -d /data/StreamData ] && [ "$(ls -A "$HOME"/BirdSongs/StreamData)" ]; then - bashio::log.warning "Container was stopped while files were still being analysed, restoring them" + bashio::log.warning "Container was stopped while files were still being analysed, restoring them" # Copy files if [ "$(ls -A /data/StreamData)" ]; then - mv -v /data/StreamData/* /tmp/StreamData/ + mv -v /data/StreamData/* "$HOME"/BirdSongs/StreamData/ fi echo "... done" echo "" # Setting permissions - chown -R pi:pi /tmp + chown -R pi:pi "$HOME"/BirdSongs # Cleaning folder rm -r /data/StreamData