Files
demat-facturation/scripts/ensure-storage-volume.sh

32 lines
1.1 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# Refuse de lancer l'application si le répertoire PDF attendu n'est pas un
# volume Docker réellement monté. Cette barrière évite de démarrer avec un
# dossier de conteneur vide après une reconstruction.
set -eu
storage_path="${STORAGE_BASE_PATH:-/app/storage}"
require_storage_volume="${REQUIRE_STORAGE_VOLUME:-false}"
if [ "$require_storage_volume" = "true" ]; then
if [ ! -d "$storage_path" ]; then
echo "[StorageGuard] Répertoire de stockage absent : $storage_path" >&2
exit 1
fi
if ! awk -v expected="$storage_path" '$2 == expected { mounted = 1 } END { exit mounted ? 0 : 1 }' /proc/mounts; then
echo "[StorageGuard] Volume persistant non monté sur $storage_path ; démarrage annulé." >&2
exit 1
fi
if [ ! -w "$storage_path" ]; then
echo "[StorageGuard] Volume persistant non inscriptible : $storage_path" >&2
exit 1
fi
else
# L’hébergement cloud n’expose pas de volume Docker local. Il utilise le
# stockage applicatif disponible à l’exécution et doit donc pouvoir démarrer.
mkdir -p "$storage_path"
fi
exec node dist/index.js