Files
bass-foundry/website/docker/40-legal-notice.sh
T
nvrl 7e1776bb04
Check and Windows preview / check (anvil) (push) Successful in 49s
Check and Windows preview / check (crucible) (push) Successful in 48s
Check and Windows preview / check (knurl) (push) Successful in 40s
Check and Windows preview / check (lathe) (push) Successful in 41s
Check and Windows preview / check (patina) (push) Successful in 56s
Check and Windows preview / check (rivet) (push) Successful in 45s
Check and Windows preview / check (temper) (push) Successful in 43s
Check and Windows preview / check (weld) (push) Successful in 1m20s
Check and Windows preview / previews (push) Successful in 1m15s
Check and Windows preview / windows (push) Successful in 2m31s
feat(website): add the fl.narl.io site
Astro site for the suite: a home page with the plugin cards, install
steps, principles, the metalwork names and the ideas on the bench, one
page per plugin, and the Impressum and privacy policy. Plugin names,
versions, download links and editor previews come from the catalog, the
wrapper manifests and docs/*/assets at build time.

Served by unprivileged nginx in Docker behind Traefik on fl.narl.io,
the same setup as proton.narl.io: no access logs, CSP 'self', no
JavaScript, legal pages filled from the environment at start.
2026-11-06 11:30:12 +01:00

75 lines
2.5 KiB
Bash
Executable File

#!/bin/sh
# Fills the Impressum and the privacy policy with the operator's details from the environment.
# Runs from the nginx image's /docker-entrypoint.d/ hook on every start. It works from pristine
# copies, so changing a variable and restarting the container is enough.
set -eu
HTML=/usr/share/nginx/html
TEMPLATES=/opt/legal-templates
PAGES="impressum/index.html datenschutz/index.html"
missing=""
for var in IMPRESSUM_NAME IMPRESSUM_STREET IMPRESSUM_CITY IMPRESSUM_EMAIL; do
eval "value=\${$var:-}"
[ -n "$value" ] || missing="$missing $var"
done
if [ -n "$missing" ]; then
echo "40-legal-notice: missing required variables:$missing" >&2
echo "40-legal-notice: refusing to serve the site without an Impressum (see .env.example)" >&2
exit 1
fi
case "$IMPRESSUM_EMAIL" in
*@*.*) ;;
*)
echo "40-legal-notice: IMPRESSUM_EMAIL does not look like an email address" >&2
exit 1
;;
esac
# One line, HTML-escaped.
html() {
printf '%s' "$1" | tr '\r\n' ' ' |
sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g' -e 's/"/\&quot;/g' -e "s/'/\&#39;/g"
}
# Every character as a numeric entity, which keeps the address away from naive scrapers.
entities() {
printf '%s' "$1" | od -An -tu1 | tr -s ' \n' '\n\n' | sed -e '/^$/d' -e 's/.*/\&#&;/' | tr -d '\n'
}
# Escapes a replacement for sed's s|…|…| (backslash, the | delimiter and &).
repl() {
printf '%s' "$1" | sed -e 's/[\\|&]/\\&/g'
}
script=$(mktemp)
trap 'rm -f "$script"' EXIT
{
echo "s|%%IMPRESSUM_NAME%%|$(repl "$(html "$IMPRESSUM_NAME")")|g"
echo "s|%%IMPRESSUM_STREET%%|$(repl "$(html "$IMPRESSUM_STREET")")|g"
echo "s|%%IMPRESSUM_CITY%%|$(repl "$(html "$IMPRESSUM_CITY")")|g"
echo "s|%%IMPRESSUM_COUNTRY%%|$(repl "$(html "${IMPRESSUM_COUNTRY:-Deutschland}")")|g"
echo "s|%%IMPRESSUM_EMAIL%%|$(repl "$(entities "$IMPRESSUM_EMAIL")")|g"
for pair in phone:IMPRESSUM_PHONE hoster:HOSTER; do
key=${pair%%:*}
var=${pair#*:}
eval "value=\${$var:-}"
if [ -n "$value" ]; then
echo "s|%%$var%%|$(repl "$(html "$value")")|g"
else
echo "s|<p data-optional=\"$key\"[^>]*>[^<]*</p>||g"
fi
done
} >"$script"
for page in $PAGES; do
sed -f "$script" "$TEMPLATES/$page" >"$HTML/$page"
if grep -q '%%[A-Z_]*%%' "$HTML/$page"; then
echo "40-legal-notice: unfilled placeholder left in $page" >&2
exit 1
fi
done
echo "40-legal-notice: filled in the Impressum and the privacy policy"