#!/bin/sh OUTPUT="${1:?usage: gen-config.sh OUTPUT_FILE}" EDITION=$(printf '%s' "${SHELLHUB_EDITION:-community}" | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]') case "$EDITION" in community|enterprise|cloud) ;; *) echo "🚫 ERROR: invalid SHELLHUB_EDITION '$EDITION': must be community, enterprise, or cloud." >&2 exit 1 ;; esac require_bool() { case "$2" in true|false) ;; *) echo "🚫 ERROR: invalid $1 '$2': must be true or false." >&2 exit 1 ;; esac } require_bool SHELLHUB_WEB_ENDPOINTS "${SHELLHUB_WEB_ENDPOINTS:-false}" SHELLHUB_MAP_STYLE="${SHELLHUB_MAP_STYLE:-outline}" case "$SHELLHUB_MAP_STYLE" in outline|openfreemap|http://*|https://*) ;; *) echo "🚫 ERROR: invalid SHELLHUB_MAP_STYLE '$SHELLHUB_MAP_STYLE': must be outline, openfreemap, or an http(s) URL to a map style." >&2 exit 1 ;; esac json_string() { printf '%s' "$1" | tr -d '\000-\010\013\014\016-\037' | sed \ -e ':a' -e '$!{N;ba' -e '}' \ -e 's/\\/\\\\/g' \ -e 's/"/\\"/g' \ -e "s/$(printf '\t')/\\\\t/g" \ -e "s/$(printf '\r')/\\\\r/g" \ -e 's/\n/\\n/g' } cat > "$OUTPUT" <