mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-04 14:54:07 +02:00
Code based on mv
This commit is contained in:
@@ -2,19 +2,34 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
if [ -d "$HOME"/BirdSongs/StreamData ]; then
|
if [ -d "$HOME"/BirdSongs/StreamData ]; then
|
||||||
bashio::log.fatal "Container stopping, saving temporary files"
|
bashio::log.fatal "Container stopping, saving temporary files."
|
||||||
|
|
||||||
# Stop the services in parallel
|
# Stop the services in parallel
|
||||||
systemctl stop birdnet_analysis &
|
if systemctl is-active --quiet birdnet_analysis; then
|
||||||
systemctl stop birdnet_recording
|
bashio::log.info "Stopping birdnet_analysis service."
|
||||||
|
systemctl stop birdnet_analysis &
|
||||||
# Ensure the target directory exists
|
|
||||||
mkdir -p /data/StreamData
|
|
||||||
|
|
||||||
# Use rsync to move files to /data/StreamData
|
|
||||||
if [ "$(ls -A "$HOME"/BirdSongs/StreamData)" ]; then
|
|
||||||
rsync -av --remove-source-files "$HOME"/BirdSongs/StreamData/ /data/StreamData/
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bashio::log.fatal "... files safe, allowing container to stop"
|
if systemctl is-active --quiet birdnet_recording; then
|
||||||
|
bashio::log.info "Stopping birdnet_recording service."
|
||||||
|
systemctl stop birdnet_recording &
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wait for both services to stop
|
||||||
|
wait
|
||||||
|
|
||||||
|
# Check if there are files in StreamData and move them to /data/StreamData
|
||||||
|
mkdir -p /data/StreamData
|
||||||
|
if [ "$(ls -A "$HOME"/BirdSongs/StreamData)" ]; then
|
||||||
|
if mv -v "$HOME"/BirdSongs/StreamData/* /data/StreamData/; then
|
||||||
|
bashio::log.info "Files successfully moved to /data/StreamData."
|
||||||
|
else
|
||||||
|
bashio::log.error "Failed to move files to /data/StreamData."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
bashio::log.info "... files safe, allowing container to stop."
|
||||||
|
else
|
||||||
|
bashio::log.info "No StreamData directory to process."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user