#!/bin/bash
# Mycelium Cloud IPv6 Website - Direct Content Injection Script
# This script updates the nginx deployment to serve the dynamic content
set -e
echo "🔍 Discovering Mycelium IPv6 addresses..."
# Fetch IPv6 addresses from cluster nodes
IPV6_ADDRESSES=$(kubectl get nodes -o jsonpath='{range .items[*]}{range .status.addresses[?(@.type=="InternalIP")]}{.address}{"\n"}{end}{end}' | grep -E '^[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+$')
if [ -z "$IPV6_ADDRESSES" ]; then
echo "❌ No IPv6 addresses found!"
exit 1
fi
echo "✅ Found IPv6 addresses:"
echo "$IPV6_ADDRESSES"
# Create the dynamic HTML content
cat > /tmp/mycelium-index.html << HTML_EOF
🌍 Mycelium Global Web Hosting
✅ SUCCESS! Mycelium IPv6 Website is Live!
This website is globally accessible via Mycelium Cloud!
This demonstrates real decentralized web hosting that anyone with Mycelium can access from anywhere in the world.
🔄 Dynamic Discovery Active
IPv6 addresses automatically discovered from cluster!
This page updates every 30 seconds to show the current cluster state.
🏗️ Technical Implementation
- Deployment: nginx pods with hostNetwork for direct IPv6 access
- Network: Direct binding to Mycelium IPv6 interfaces
- Global Access: Available on all cluster Mycelium IPv6 addresses
- Dynamic Discovery: IPv6 addresses fetched via kubectl automatically
- Content: Auto-generated with current cluster information
🌐 Global Access URLs
Your website is accessible via any Mycelium IPv6:
HTML_EOF
# Add each IPv6 address to the HTML
while IFS= read -r ipv6; do
echo " http://[$ipv6]:80 " >> /tmp/mycelium-index.html
done <<< "$IPV6_ADDRESSES"
cat >> /tmp/mycelium-index.html << HTML_EOF
Anyone with Mycelium can access your website from anywhere in the world!
🚀 IPv6 Connectivity Test
Test if Mycelium IPv6 connectivity is working:
curl http://[$(echo "$IPV6_ADDRESSES" | head -1)]:80
All 6 IPv6 addresses should respond with this website content!
Last updated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
IPv6 addresses discovered: $(echo "$IPV6_ADDRESSES" | wc -l)
Status: 🟢 LIVE on Mycelium Cloud
Mycelium Cloud • Decentralized Global Internet Infrastructure
Deploy once, access worldwide! 🌍
Peer-to-Peer IPv6 Website Hosting
HTML_EOF
echo "📝 Generated dynamic HTML with $(echo "$IPV6_ADDRESSES" | wc -l) IPv6 addresses"
# Update all nginx pods with the new content
echo "🔄 Updating nginx containers with dynamic content..."
# Get all nginx-mycelium-global pods and inject the content
PODS=$(kubectl get pods -l app=nginx-mycelium-global -o name 2>/dev/null || true)
if [ -z "$PODS" ]; then
echo "⚠️ No nginx-mycelium-global pods found, you may need to deploy them first"
else
for pod in $PODS; do
echo "📤 Updating $pod..."
kubectl cp /tmp/mycelium-index.html $pod:/usr/share/nginx/html/index.html || echo "Failed to update $pod"
done
fi
echo "✅ Dynamic content update complete!"
echo "🌐 Your website is now live on Mycelium Cloud!"
echo "🌍 Test with: curl http://[$(echo "$IPV6_ADDRESSES | head -1)]:80"