#!/usr/bin/env bash # # Assemble the getlibreportal docroot — the website + install.sh + release # channels — into the served data dir. Run on a FULL repo checkout (build/release # machine), since it needs ../../site and ../../dist (both export-ignored, i.e. # not in release tarballs). # # 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/getlibreportal/publish.sh /libreportal-containers/getlibreportal/data # # Layout produced: # / ← built website (repo: site/) # /install.sh ← bootstrap installer (repo: install.sh) # //… ← release manifests + tarballs (repo: dist//) set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT="$(cd "$HERE/../.." && pwd)" # repo root (containers/getlibreportal -> ../../) TARGET="${1:-$HERE/data}" echo "Assembling getlibreportal docroot -> $TARGET" mkdir -p "$TARGET" # Clean only the things we manage (keep the dir itself / its mount). rm -rf "${TARGET:?}"/* "${TARGET:?}"/.??* 2>/dev/null || true # 1. Website (optional — skip cleanly without the toolchain). if [[ -d "$ROOT/site" ]] && command -v npm >/dev/null 2>&1; then ( cd "$ROOT/site" && npm install --silent && npm run build ) cp -a "$ROOT/site/dist/." "$TARGET/" 2>/dev/null || true echo " ✓ website" else echo " ! site build skipped (no site/ or no npm) — install.sh + releases still published" fi # 2. Bootstrap installer. if [[ -f "$ROOT/install.sh" ]]; then cp -f "$ROOT/install.sh" "$TARGET/install.sh"; echo " ✓ install.sh"; fi # 3. Release channels (from scripts/release/make_release.sh). if [[ -d "$ROOT/dist" ]]; then for ch in "$ROOT/dist"/*/; do [[ -d "$ch" ]] || continue n="$(basename "$ch")"; mkdir -p "$TARGET/$n"; cp -f "$ch"/* "$TARGET/$n/" 2>/dev/null || true echo " ✓ channel $n" done else echo " ! no dist/ — run scripts/release/make_release.sh first" fi echo "Done. Restart the container to serve it."