#!/bin/sh # GK2 Hub Landing Page Generator # Reads from HAProxy, Streamlit, and MetaBlogizer configs # Copyright (C) 2025 CyberMind.fr OUTPUT="/www/gk2-hub/index.html" # Icons mapping get_icon() { case "$1" in evolution|secubox_evolution) echo "๐Ÿ“ˆ" ;; control|secubox_control) echo "๐ŸŽ›๏ธ" ;; fabricator|fabric) echo "๐Ÿญ" ;; yijing*|yling|hermes) echo "โ˜ฏ๏ธ" ;; play) echo "๐ŸŽฎ" ;; console|secubox_console) echo "๐Ÿ–ฅ๏ธ" ;; glances) echo "๐Ÿ“Š" ;; lldh) echo "๐Ÿ“–" ;; wanted|want) echo "๐ŸŽฏ" ;; gandalf) echo "๐Ÿง™" ;; cyberzine) echo "๐Ÿ’พ" ;; devel|dev) echo "๐Ÿ‘จโ€๐Ÿ’ป" ;; c3box) echo "๐Ÿ“ฆ" ;; gk2) echo "โœจ" ;; secubox) echo "๐Ÿ›ก๏ธ" ;; press|presse) echo "๐Ÿ“ฐ" ;; oracle) echo "๐Ÿ”ฎ" ;; bazi*|pix|bweep|bweek|BASIC) echo "๐Ÿ€„" ;; slides|sliders) echo "๐ŸŽž๏ธ" ;; comic) echo "๐Ÿ“š" ;; eval) echo "๐Ÿงช" ;; sappix) echo "๐Ÿ”ง" ;; ftvm) echo "๐Ÿ“บ" ;; cineposter*|cpf) echo "๐ŸŽฌ" ;; wuyun) echo "๐ŸŒฌ๏ธ" ;; hello) echo "๐Ÿ‘‹" ;; tube|peertube) echo "๐Ÿ“บ" ;; social|gotosocial) echo "๐Ÿ˜" ;; wazuh) echo "๐Ÿ”’" ;; webmail|mail) echo "๐Ÿ“ง" ;; media|jellyfin) echo "๐ŸŽฌ" ;; pdf|papyrus) echo "๐Ÿ“„" ;; geo|gondwana) echo "๐ŸŒ" ;; clock) echo "๐Ÿ•" ;; money) echo "๐Ÿ’ฐ" ;; osint) echo "๐Ÿ”" ;; flash) echo "โšก" ;; client) echo "๐Ÿ‘ค" ;; mvox) echo "๐ŸŽค" ;; *) echo "๐Ÿš€" ;; esac } # Generate HTML cat > "$OUTPUT" << 'HTML_HEAD' GKยฒ Hub - SecuBox Services

โšก GKยฒ Hub

SecuBox Service Directory โ€ข gk2.secubox.in

HTML_HEAD # Streamlit Apps Section echo '
' >> "$OUTPUT" echo '

๐Ÿš€ Streamlit Apps

' >> "$OUTPUT" echo '
' >> "$OUTPUT" # Get all streamlit instances from UCI config grep -E "^config instance" /etc/config/streamlit 2>/dev/null | while read line; do section=$(echo "$line" | sed "s/config instance '\([^']*\)'/\1/") [ -z "$section" ] && continue # Read instance config app=$(uci -q get streamlit.$section.app) port=$(uci -q get streamlit.$section.port) enabled=$(uci -q get streamlit.$section.enabled) domain=$(uci -q get streamlit.$section.domain) [ "$enabled" != "1" ] && continue [ -z "$app" ] && continue [ -z "$port" ] && continue # Check if there's a HAProxy vhost for this app if [ -n "$domain" ]; then url="https://$domain" else # Check HAProxy for matching vhost vhost_domain=$(uci show haproxy 2>/dev/null | grep -E "\.domain=.*${section}.*gk2\.secubox\.in" | head -1 | sed "s/.*domain='\([^']*\)'/\1/") if [ -n "$vhost_domain" ]; then url="https://$vhost_domain" else url="http://192.168.255.1:$port" fi fi icon=$(get_icon "$section") display_name="$section" cat >> "$OUTPUT" << EOF
$icon
$display_name
$app :$port
EOF done echo '
' >> "$OUTPUT" echo '
' >> "$OUTPUT" # MetaBlogizer Section echo '
' >> "$OUTPUT" echo '

๐Ÿ“ฐ MetaBlogizer Webs

' >> "$OUTPUT" echo '
' >> "$OUTPUT" for site in $(ls -1 /srv/metablogizer/sites/ 2>/dev/null | sort); do [ -f "/srv/metablogizer/sites/$site/index.html" ] || continue icon=$(get_icon "$site") # Try to get domain from UCI section="site_$(echo "$site" | tr '-' '_')" domain=$(uci -q get metablogizer.$section.domain) # Default URL mapping - try gk2.secubox.in subdomain, fallback to maegia.tv if [ -z "$domain" ]; then # Check if HAProxy vhost exists for gk2.secubox.in vhost_domain=$(uci show haproxy 2>/dev/null | grep -E "\.domain='${site}\.gk2\.secubox\.in'" | head -1 | sed "s/.*domain='\([^']*\)'/\1/") if [ -n "$vhost_domain" ]; then url="https://$vhost_domain" else # Fallback to maegia.tv for some known sites case "$site" in gandalf) url="https://gandalf.maegia.tv" ;; cyberzine) url="https://cyberzine.maegia.tv" ;; devel) url="https://devel.maegia.tv" ;; c3box) url="https://c3box.maegia.tv" ;; gk2) url="https://gk2.maegia.tv" ;; *) url="https://${site}.gk2.secubox.in" ;; esac fi else url="https://$domain" fi cat >> "$OUTPUT" << EOF
$icon
$site
EOF done echo '
' >> "$OUTPUT" echo '
' >> "$OUTPUT" # Infrastructure Section echo '
' >> "$OUTPUT" echo '

๐Ÿ”ง Infrastructure

' >> "$OUTPUT" echo ' ' >> "$OUTPUT" echo '
' >> "$OUTPUT" # Footer cat >> "$OUTPUT" << EOF
EOF echo "Generated $OUTPUT"