mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-17 01:48:16 +01:00
Code based on mv
This commit is contained in:
@@ -2,19 +2,34 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
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
|
||||
systemctl stop birdnet_analysis &
|
||||
systemctl stop birdnet_recording
|
||||
|
||||
# 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/
|
||||
if systemctl is-active --quiet birdnet_analysis; then
|
||||
bashio::log.info "Stopping birdnet_analysis service."
|
||||
systemctl stop birdnet_analysis &
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user