- verify.sh now calls bootstrap_runtime_dir after load_config; previously a reset-then-verify flow let Docker auto-create a root-owned mount source - common.sh: fail with clear guidance when data root exists but is not writable - README: configuration section, bootstrap usage, selftest entry point - BUILD-LOG: Phase 5 entries with corrections E2E (clean slate): 20/20 selftests; bootstrap idempotent; config-driven hello/verify MOSAIC_HELLO_OK; negative marker exit 1; reset + rerun green; config checksum unchanged across the entire flow. Closes #4
39 lines
1.5 KiB
Bash
Executable File
39 lines
1.5 KiB
Bash
Executable File
# Shared helpers for the Mosaic host scripts. Not a documented entry point.
|
|
|
|
POC_ROOT_MARKER=".mosaic-poc-root"
|
|
|
|
# Load and validate the Mosaic configuration (config.json), exporting
|
|
# MOSAIC_DATA_ROOT, MOSAIC_PROVIDER, and MOSAIC_MODEL.
|
|
#
|
|
# Fails closed: a missing or invalid configuration aborts the calling
|
|
# script before any container or filesystem mutation. Run paths never
|
|
# auto-bootstrap; use scripts/bootstrap.sh explicitly.
|
|
load_config() {
|
|
local config_env
|
|
if ! config_env="$(node scripts/mosaic-config.mjs env)"; then
|
|
echo "common: configuration load failed" >&2
|
|
exit 1
|
|
fi
|
|
eval "$config_env"
|
|
export MOSAIC_DATA_ROOT MOSAIC_PROVIDER MOSAIC_MODEL
|
|
MOSAIC_DEV_DIR="$MOSAIC_DATA_ROOT"
|
|
}
|
|
|
|
# Ensure the configured runtime data directory exists and carries this
|
|
# project's ownership marker. The marker is what scripts/reset.sh requires
|
|
# before it will delete anything.
|
|
bootstrap_runtime_dir() {
|
|
if [ -d "$MOSAIC_DEV_DIR" ]; then
|
|
if [ ! -w "$MOSAIC_DEV_DIR" ] || [ ! -x "$MOSAIC_DEV_DIR" ]; then
|
|
echo "bootstrap: $MOSAIC_DEV_DIR exists but is not writable by $(id -un)" >&2
|
|
echo "bootstrap: a root-owned directory here is usually leftover from a" >&2
|
|
echo "bootstrap: Docker-created mount source; remove it and rerun." >&2
|
|
exit 1
|
|
fi
|
|
else
|
|
mkdir -p "$MOSAIC_DEV_DIR"
|
|
echo "bootstrap: created $MOSAIC_DEV_DIR"
|
|
fi
|
|
touch "$MOSAIC_DEV_DIR/$POC_ROOT_MARKER"
|
|
}
|