A lexicon-driven AppView for ATProto.
1#!/bin/sh
2set -e
3
4BP="${BASE_PATH:-}"
5STATIC="${STATIC_DIR:-/srv/static}"
6SENTINEL="/__HAPPYVIEW_BP__"
7MARKER="${STATIC}/.base-path-pending"
8
9# Only run replacement once (marker is created during Docker build)
10if [ -f "$MARKER" ]; then
11 if [ -n "$BP" ]; then
12 # Validate: must start with /
13 case "$BP" in
14 /*) ;;
15 *) echo "ERROR: BASE_PATH must start with '/' (got: $BP)" >&2; exit 1 ;;
16 esac
17 # Strip trailing slash
18 BP="${BP%/}"
19
20 # Replace sentinel string in static files with actual base path
21 find "${STATIC}" -type f \( -name '*.html' -o -name '*.js' -o -name '*.css' -o -name '*.txt' \) \
22 -exec sed -i "s|${SENTINEL}|${BP}|g" {} +
23 else
24 # No base path: remove sentinel string from static files
25 find "${STATIC}" -type f \( -name '*.html' -o -name '*.js' -o -name '*.css' -o -name '*.txt' \) \
26 -exec sed -i "s|${SENTINEL}||g" {} +
27 fi
28
29 rm "$MARKER"
30fi
31
32exec happyview "$@"