#!/usr/bin/env bash set -euo pipefail FALLBACK_DIR="/app/data/switch/packages" PRIMARY_BASE="/data/switch/packages" USE_DIR="$PRIMARY_BASE" # Thử tạo dir trong /data (có thể fail nếu chưa bật persistent storage) if mkdir -p "$PRIMARY_BASE" 2>/dev/null; then echo "[init] Using primary served dir: $PRIMARY_BASE" else echo "[init] WARNING: cannot write to /data. Falling back to $FALLBACK_DIR" USE_DIR="$FALLBACK_DIR" mkdir -p "$FALLBACK_DIR" fi # In ra cho dễ debug ls -ld /data || true ls -ld "$PRIMARY_BASE" || true ls -ld "$FALLBACK_DIR" || true echo "[init] Final served dir in use (exists): $USE_DIR" # Chạy server exec /app/TinfoilWebServer