#!/bin/bash # ========================================= # 🌐 AI Brain Core Subscription Loader + Auto-Healer # Reads subscription.env, heals sub-brains, then launches # ========================================= BASE_DIR="$HOME/Desktop/AI_Brain" SUBS_FILE="$BASE_DIR/subscription.env" LOG_DIR="$BASE_DIR/logs" mkdir -p "$LOG_DIR" if [ ! -f "$SUBS_FILE" ]; then echo "❌ subscription.env not found in $BASE_DIR" exit 1 fi echo "πŸ”Ž Reading subscriptions from $SUBS_FILE..." # Load subscription settings set -a source "$SUBS_FILE" set +a heal_and_launch() { local NAME=$1 local PATH=$2 local VAR=$3 if [ "${!VAR}" = "enabled" ]; then echo "🩹 Healing $NAME..." if [ -x "$PATH/heal.sh" ]; then "$PATH/heal.sh" >> "$LOG_DIR/${NAME}_heal.log" 2>&1 else # Default healing if no heal.sh exists find "$PATH" -type f -name "*.sh" -exec chmod +x {} \; find "$PATH" -type f -print0 | xargs -0 dos2unix 2>/dev/null || true python3 -m compileall -q "$PATH" 2>/dev/null || true fi echo "πŸš€ Launching $NAME..." if [ -x "$PATH/launch.sh" ]; then nohup "$PATH/launch.sh" > "$LOG_DIR/${NAME}.out" 2>&1 & sleep 1 echo "βœ… $NAME online (log: $LOG_DIR/${NAME}.out)" else echo "⚠️ $NAME launch.sh not found or not executable ($PATH)" fi else echo "⏸️ $NAME is disabled by subscription" fi } # === SUB-BRAINS === heal_and_launch "Healer Pro Pack" "$HOME/Desktop/healer-pro-pack" "HEALER_PRO_PACK" heal_and_launch "AI Music Evolution" "$HOME/Desktop/AI_Music_Evolution" "AI_MUSIC_EVOLUTION" heal_and_launch "Social Dashboard" "$HOME/Desktop/Social_Dashboard" "SOCIAL_DASHBOARD" heal_and_launch "DevOps Agents" "$HOME/Desktop/devops_agents" "DEVOPS_AGENTS" heal_and_launch "API Scouts" "$HOME/Desktop/api_scouts" "API_SCOUTS" echo "βœ… Subscription loader finished."