mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-03 06:14:07 +02:00
Avoid hardcoding /tmp https://github.com/alexbelgium/hassio-addons/issues/1369#issuecomment-2088623801
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/usr/bin/with-contenv bashio
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
if [ -d /tmp/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 &
|
systemctl stop birdnet_analysis &
|
||||||
systemctl stop birdnet_recording
|
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
|
mkdir -p /data/StreamData
|
||||||
if [ "$(ls -A /tmp/StreamData)" ]; then
|
if [ "$(ls -A "$HOME"/BirdSongs/StreamData)" ]; then
|
||||||
mv -v /tmp/StreamData/* /data/StreamData/
|
mv -v "$HOME"/BirdSongs/StreamData/* /data/StreamData/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bashio::log.fatal "... files safe, allowing container to stop"
|
bashio::log.fatal "... files safe, allowing container to stop"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/usr/bin/with-contenv bashio
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
# Check if there are files in /tmp/StreamData and move them to /data/StreamData
|
# Check if there are files in "$HOME"/BirdSongs/StreamData and move them to /data/StreamData
|
||||||
if [ -d /data/StreamData ] && [ "$(ls -A /tmp/StreamData)" ]; then
|
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
|
# Copy files
|
||||||
if [ "$(ls -A /data/StreamData)" ]; then
|
if [ "$(ls -A /data/StreamData)" ]; then
|
||||||
mv -v /data/StreamData/* /tmp/StreamData/
|
mv -v /data/StreamData/* "$HOME"/BirdSongs/StreamData/
|
||||||
fi
|
fi
|
||||||
echo "... done"
|
echo "... done"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Setting permissions
|
# Setting permissions
|
||||||
chown -R pi:pi /tmp
|
chown -R pi:pi "$HOME"/BirdSongs
|
||||||
|
|
||||||
# Cleaning folder
|
# Cleaning folder
|
||||||
rm -r /data/StreamData
|
rm -r /data/StreamData
|
||||||
|
|||||||
Reference in New Issue
Block a user