#!/bin/sh # SPDX-License-Identifier: MIT # SecuBox Landing Page Generator # Copyright (C) 2025 CyberMind.fr . /lib/functions.sh UCI_CONFIG="service-registry" OUTPUT_PATH="/www/secubox-services.html" # Get output path from config config_load "$UCI_CONFIG" config_get OUTPUT_PATH main landing_path "$OUTPUT_PATH" # Get services JSON SERVICES_JSON=$(ubus call luci.service-registry list_services 2>/dev/null) if [ -z "$SERVICES_JSON" ]; then echo "Error: Could not fetch services" exit 1 fi # Get hostname HOSTNAME=$(uci -q get system.@system[0].hostname || echo "SecuBox") # Generate HTML cat > "$OUTPUT_PATH" <<'HTMLHEAD' SecuBox Services

SecuBox Services

Published endpoints and access links

HTMLHEAD # Replace placeholder with actual JSON using awk (more reliable than sed for JSON) TMP_OUTPUT="${OUTPUT_PATH}.tmp" awk -v json="$SERVICES_JSON" '{gsub(/SERVICES_JSON_PLACEHOLDER/, json); print}' "$OUTPUT_PATH" > "$TMP_OUTPUT" mv "$TMP_OUTPUT" "$OUTPUT_PATH" # Ensure web server can read the file chmod 644 "$OUTPUT_PATH" echo "Landing page generated: $OUTPUT_PATH"