50 lines
1.4 KiB
Bash
Executable File
50 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Documentation: render the diagrams, and serve the pages from a throwaway nginx container.
|
|
# Usage: docs.sh serve | graphs
|
|
# Notes: docs/notes/docs.md
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
|
|
source ./lib/config.sh
|
|
load_config
|
|
|
|
REPO="$(cd .. && pwd)"
|
|
DOCS_PORT="${DOCS_PORT:-$((HTTP_PORT + 4))}" # +4 sits inside this env's block
|
|
|
|
serve() {
|
|
if [ ! -f "$REPO/docs/index.html" ]; then
|
|
echo "no docs/index.html" >&2
|
|
exit 1
|
|
fi
|
|
echo "docs for '$CLUSTER' on http://localhost:${DOCS_PORT}"
|
|
echo " (ctrl-c to stop; nothing is installed and nothing persists)"
|
|
docker run --rm \
|
|
--name "${CLUSTER}-docs" \
|
|
-p "${DOCS_PORT}:80" \
|
|
-v "$REPO/docs:/usr/share/nginx/html:ro" \
|
|
nginx:alpine
|
|
}
|
|
|
|
graphs() {
|
|
if ! command -v dot >/dev/null 2>&1; then
|
|
echo "graphviz not found — install with: sudo apt install graphviz" >&2
|
|
echo "(only needed to re-render; the committed .svg files already work)" >&2
|
|
exit 1
|
|
fi
|
|
shopt -s nullglob
|
|
local found=0 f out
|
|
for f in "$REPO"/docs/graphs/*.dot; do
|
|
out="${f%.dot}.svg"
|
|
echo " graphviz $(basename "$f") → $(basename "$out")"
|
|
dot -Tsvg "$f" -o "$out"
|
|
found=1
|
|
done
|
|
[ "$found" -eq 1 ] || echo " no .dot files in docs/graphs/"
|
|
}
|
|
|
|
case "${1:-serve}" in
|
|
serve) serve ;;
|
|
graphs) graphs ;;
|
|
*) echo "usage: $0 [serve|graphs]" >&2; exit 1 ;;
|
|
esac
|