#!/bin/sh # Container start-up: point the UI at the API, and (when API_INTERNAL_URL is set) # forward the fediverse paths on this domain to the API. set -e case "$API_BASE_URL" in http://*|https://*) ;; *) echo "API_BASE_URL must start with http:// or https://" >&2; exit 1 ;; esac url=$(printf '%s' "$API_BASE_URL" | sed 's#/*$##; s#["\\]##g') cat > /usr/share/nginx/html/config.js < /etc/nginx/scrobbler/federation.conf exit 0 fi case "$API_INTERNAL_URL" in http://*|https://*) ;; *) echo "API_INTERNAL_URL must look like http://api:8000" >&2; exit 1 ;; esac upstream=$(printf '%s' "$API_INTERNAL_URL" | sed 's#/*$##') case "$upstream" in *://*/*) echo "API_INTERNAL_URL must not have a path" >&2; exit 1 ;; esac # Resolve the API's name per request (not once at start-up), so the UI starts even if # the API isn't up yet and keeps working when the API container is replaced. nameserver=$(awk '/^nameserver/ { print $2; exit }' /etc/resolv.conf) case "$nameserver" in *:*) nameserver="[$nameserver]" ;; esac cat > /etc/nginx/scrobbler/federation.conf <