From a89a603f2af3ca9375da6ec1cb0782758a7478a0 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 1 May 2024 15:56:22 +0200 Subject: [PATCH] Create 02-restorestreamdata --- .../etc/cont-init.d/02-restorestreamdata | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata diff --git a/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata b/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata new file mode 100644 index 000000000..e46b8d868 --- /dev/null +++ b/birdnet-pi/rootfs/etc/cont-init.d/02-restorestreamdata @@ -0,0 +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 + + bashio::log.warning "Container was stopped while files were still being analysed, restoring them" + + # Copy files + if [ "$(ls -A /data/StreamData)" ]; then + mv /data/StreamData/* /tmp/StreamData/ + fi + echo "... done" + echo "" + + # Cleaning folder + rm -r /data/StreamData + +fi +