#!/usr/bin/env bash # # Build the LibrePortal website (Eleventy) and publish it into the served docroot. # Run on a full repo checkout (it reads ../*/*.config to build the app catalogue). # # Usage: publish.sh [TARGET_DIR] # TARGET_DIR defaults to ./data (next to this script). On a host where the app # is installed, pass its live data dir, e.g.: # containers/weblibreportal/publish.sh /libreportal-containers/weblibreportal/data set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" TARGET="${1:-$HERE/data}" command -v npm >/dev/null 2>&1 || { echo "publish.sh: npm is required to build the website" >&2; exit 1; } echo "Building the website ..." ( cd "$HERE" && npm install --silent && npm run build ) # → ./dist (runs gen-data + eleventy) echo "Publishing -> $TARGET" mkdir -p "$TARGET" rm -rf "${TARGET:?}"/* "${TARGET:?}"/.??* 2>/dev/null || true cp -a "$HERE/dist/." "$TARGET/" echo "Done. Restart the container to serve it."