diff --git a/package/secubox/secubox-app-gk2hub/Makefile b/package/secubox/secubox-app-gk2hub/Makefile new file mode 100644 index 00000000..190eead6 --- /dev/null +++ b/package/secubox/secubox-app-gk2hub/Makefile @@ -0,0 +1,43 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=secubox-app-gk2hub +PKG_VERSION:=0.1.0 +PKG_RELEASE:=1 + +PKG_MAINTAINER:=CyberMind +PKG_LICENSE:=MIT + +include $(INCLUDE_DIR)/package.mk + +define Package/secubox-app-gk2hub + SECTION:=secubox + CATEGORY:=SecuBox + TITLE:=GK2 Hub Landing Page Generator + DEPENDS:=+uhttpd + PKGARCH:=all +endef + +define Package/secubox-app-gk2hub/description + Dynamic landing page generator for GK2 SecuBox services. + Aggregates Streamlit apps, MetaBlogizer sites, and infrastructure + services into a single service directory page. +endef + +define Build/Compile +endef + +define Package/secubox-app-gk2hub/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) ./files/usr/bin/gk2hub-generate $(1)/usr/bin/ + + $(INSTALL_DIR) $(1)/www/gk2-hub + $(INSTALL_DATA) ./files/www/gk2-hub/index.html $(1)/www/gk2-hub/ +endef + +define Package/secubox-app-gk2hub/postinst +#!/bin/sh +[ -n "$${IPKG_INSTROOT}" ] || /usr/bin/gk2hub-generate >/dev/null 2>&1 || true +exit 0 +endef + +$(eval $(call BuildPackage,secubox-app-gk2hub)) diff --git a/package/secubox/secubox-app-gk2hub/files/usr/bin/gk2hub-generate b/package/secubox/secubox-app-gk2hub/files/usr/bin/gk2hub-generate new file mode 100644 index 00000000..f36dee9c --- /dev/null +++ b/package/secubox/secubox-app-gk2hub/files/usr/bin/gk2hub-generate @@ -0,0 +1,222 @@ +#!/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 "๐Ÿ‘‹" ;; + *) 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 if no domain configured + if [ -z "$domain" ]; then + case "$site" in + lldh) url="https://lldh.gk2.secubox.in" ;; + want) url="https://wanted.gk2.secubox.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://secubox.in/gk2/$site" ;; + esac + else + url="https://$domain" + fi + + cat >> "$OUTPUT" << EOF + +
$icon
+
$site
+
+EOF +done + +echo '
' >> "$OUTPUT" +echo '
' >> "$OUTPUT" + +# Infrastructure Section +echo ' ' >> "$OUTPUT" + +# Footer +cat >> "$OUTPUT" << EOF +
+ GKยฒ โ€ข CyberMind.FR โ€ข SecuBox v0.18 โ€ข $(date +%Y) +
Auto-generated $(date '+%Y-%m-%d %H:%M')
+
+
+ + +EOF + +echo "Generated $OUTPUT" diff --git a/package/secubox/secubox-app-gk2hub/files/www/gk2-hub/index.html b/package/secubox/secubox-app-gk2hub/files/www/gk2-hub/index.html new file mode 100644 index 00000000..179ea178 --- /dev/null +++ b/package/secubox/secubox-app-gk2hub/files/www/gk2-hub/index.html @@ -0,0 +1,20 @@ + + + + + + GKยฒ Hub - SecuBox Services + + + +
+

โšก GKยฒ Hub

+

Generating service directory...

+

Run: gk2hub-generate

+
+ +