all-in-one backend using docker

This commit is contained in:
2025-08-15 18:13:40 +02:00
parent fdfa6e9b80
commit 0d101dec1d
6 changed files with 146 additions and 123 deletions

39
post_upload.sh Normal file
View File

@ -0,0 +1,39 @@
#!/bin/bash
BASE_DIR="/files"
CURRENT_DIR="$BASE_DIR/current"
mkdir -p "$CURRENT_DIR"
# Store last SHA256 checksums for each camera
declare -A LAST_SHA
echo "[Watcher] Starting to monitor subfolders in $BASE_DIR ..."
while true; do
for CAM_DIR in "$BASE_DIR"/msvcam*; do
[ -d "$CAM_DIR" ] || continue
CAM_NAME=$(basename "$CAM_DIR")
OUT_FILE="$CURRENT_DIR/${CAM_NAME}.avif"
# Find the newest image
NEWEST_FILE=$(find "$CAM_DIR" -type f -iregex ".*\.\(jpg\|jpeg\|png\|bmp\|tif\|tiff\)" -printf "%T@ %p\n" | sort -n | tail -1 | awk '{print $2}')
if [ -n "$NEWEST_FILE" ]; then
# Calculate SHA256 of the newest image
SHA=$(sha256sum "$NEWEST_FILE" | awk '{print $1}')
# Check if this file has already been converted
if [ "${LAST_SHA[$CAM_NAME]}" != "$SHA" ]; then
echo "[Watcher] New or changed file detected for $CAM_NAME: $NEWEST_FILE"
avifenc "$NEWEST_FILE" "$OUT_FILE"
sync
LAST_SHA[$CAM_NAME]="$SHA"
else
echo "[Watcher] No change detected for $CAM_NAME, skipping conversion."
fi
fi
done
sleep 5
done