mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-08-09 14:42:29 +02:00
Improve code
This commit is contained in:
@@ -7,14 +7,17 @@ if [ -d /data/StreamData ]; then
|
|||||||
|
|
||||||
# Check if there are .wav files in /data/StreamData
|
# Check if there are .wav files in /data/StreamData
|
||||||
if find /data/StreamData -type f -name "*.wav" | grep -q .; then
|
if find /data/StreamData -type f -name "*.wav" | grep -q .; then
|
||||||
bashio::log.fatal "Restoring .wav files from /data/StreamData to $HOME/BirdSongs/StreamData."
|
bashio::log.warning "Restoring .wav files from /data/StreamData to $HOME/BirdSongs/StreamData."
|
||||||
|
|
||||||
|
# Count the number of .wav files to be moved
|
||||||
|
file_count=$(find /data/StreamData -type f -name "*.wav" | wc -l)
|
||||||
|
echo "... found $file_count .wav files to restore."
|
||||||
|
|
||||||
# Move the .wav files using `mv` to avoid double log entries
|
# Move the .wav files using `mv` to avoid double log entries
|
||||||
mv -v /data/StreamData/*.wav "$HOME"/BirdSongs/StreamData/
|
mv -v /data/StreamData/*.wav "$HOME"/BirdSongs/StreamData/
|
||||||
|
|
||||||
bashio::log.fatal "... files restored successfully, allowing container to stop."
|
|
||||||
else
|
else
|
||||||
bashio::log.info "No .wav files found to restore."
|
echo "... no .wav files found to restore."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean up the source folder if empty
|
# Clean up the source folder if empty
|
||||||
|
|||||||
Reference in New Issue
Block a user