Buckets:
| # Copyright (c) 2025 Joshua Hendricks Cole (DBA: Corporation of Light). All Rights Reserved. PATENT PENDING. | |
| # | |
| # ECH0 EMPIRE LAUNCH SCRIPT | |
| # ========================= | |
| # | |
| # Launches the entire ECH0 autonomous business empire in production mode. | |
| # Designed for 10+ years continuous operation with auto-restart on boot. | |
| # | |
| # USAGE: | |
| # ./LAUNCH_ECH0_EMPIRE.sh # Launch all agents | |
| # ./LAUNCH_ECH0_EMPIRE.sh --status # Check status | |
| # ./LAUNCH_ECH0_EMPIRE.sh --shutdown # Graceful shutdown | |
| # ./LAUNCH_ECH0_EMPIRE.sh --install # Install as system service | |
| set -euo pipefail | |
| # Configuration | |
| ECH0_HOME="/Users/noone" | |
| ECH0_DATA_DIR="$HOME/.ech0_data" | |
| ECH0_LOG_DIR="$ECH0_DATA_DIR/logs" | |
| ORCHESTRATOR_SCRIPT="$ECH0_HOME/ech0_master_orchestrator.py" | |
| ORCHESTRATOR_PID_FILE="$ECH0_DATA_DIR/orchestrator.pid" | |
| ORCHESTRATOR_LOG="$ECH0_LOG_DIR/orchestrator.log" | |
| # Colors | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| BLUE='\033[0;34m' | |
| NC='\033[0m' # No Color | |
| # Ensure directories exist | |
| mkdir -p "$ECH0_DATA_DIR" "$ECH0_LOG_DIR" | |
| # Logging function | |
| log_info() { | |
| echo -e "${GREEN}[INFO]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$ORCHESTRATOR_LOG" | |
| } | |
| log_warn() { | |
| echo -e "${YELLOW}[WARN]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$ORCHESTRATOR_LOG" | |
| } | |
| log_error() { | |
| echo -e "${RED}[ERROR]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$ORCHESTRATOR_LOG" | |
| } | |
| log_section() { | |
| echo -e "\n${BLUE}════════════════════════════════════════════════════════════════${NC}" | |
| echo -e "${BLUE} $1${NC}" | |
| echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}\n" | |
| } | |
| # Check if orchestrator is running | |
| is_running() { | |
| if [ -f "$ORCHESTRATOR_PID_FILE" ]; then | |
| PID=$(cat "$ORCHESTRATOR_PID_FILE") | |
| if ps -p "$PID" > /dev/null 2>&1; then | |
| return 0 | |
| else | |
| # PID file exists but process is dead - clean up | |
| rm -f "$ORCHESTRATOR_PID_FILE" | |
| return 1 | |
| fi | |
| fi | |
| return 1 | |
| } | |
| # Launch the orchestrator | |
| launch_orchestrator() { | |
| log_section "LAUNCHING ECH0 BUSINESS EMPIRE" | |
| # Check if already running | |
| if is_running; then | |
| log_warn "ECH0 Orchestrator is already running (PID: $(cat $ORCHESTRATOR_PID_FILE))" | |
| log_info "Use --status to check status or --shutdown to stop" | |
| exit 1 | |
| fi | |
| # Check if orchestrator script exists | |
| if [ ! -f "$ORCHESTRATOR_SCRIPT" ]; then | |
| log_error "Orchestrator script not found: $ORCHESTRATOR_SCRIPT" | |
| exit 1 | |
| fi | |
| # Check Python version | |
| PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}' | cut -d. -f1,2) | |
| log_info "Python version: $PYTHON_VERSION" | |
| if ! command -v python3 &> /dev/null; then | |
| log_error "python3 not found - please install Python 3.8+" | |
| exit 1 | |
| fi | |
| # Pre-flight checks | |
| log_info "Running pre-flight checks..." | |
| # Check disk space (need at least 10GB free) | |
| DISK_AVAIL=$(df -h "$ECH0_DATA_DIR" | tail -1 | awk '{print $4}' | sed 's/G//') | |
| if [ "${DISK_AVAIL%%.*}" -lt 10 ]; then | |
| log_warn "Low disk space: ${DISK_AVAIL}GB available (recommend 10GB+)" | |
| fi | |
| # Check if required Python packages are installed | |
| log_info "Checking Python dependencies..." | |
| python3 -c "import sqlite3, asyncio, json" 2>/dev/null || { | |
| log_error "Missing required Python packages" | |
| exit 1 | |
| } | |
| log_info "Pre-flight checks passed ✓" | |
| # Launch orchestrator in background | |
| log_info "Starting Master Orchestrator..." | |
| nohup python3 "$ORCHESTRATOR_SCRIPT" --launch-all > "$ORCHESTRATOR_LOG" 2>&1 & | |
| ORCHESTRATOR_PID=$! | |
| # Save PID | |
| echo "$ORCHESTRATOR_PID" > "$ORCHESTRATOR_PID_FILE" | |
| # Wait a moment and check if it's still running | |
| sleep 3 | |
| if ps -p "$ORCHESTRATOR_PID" > /dev/null 2>&1; then | |
| log_info "✓ ECH0 Master Orchestrator started successfully (PID: $ORCHESTRATOR_PID)" | |
| log_info "✓ All 9 subordinate agents launching..." | |
| log_info "" | |
| log_info "Monitor logs: tail -f $ORCHESTRATOR_LOG" | |
| log_info "Check status: ./LAUNCH_ECH0_EMPIRE.sh --status" | |
| log_info "Shutdown: ./LAUNCH_ECH0_EMPIRE.sh --shutdown" | |
| log_section "ECH0 EMPIRE IS NOW AUTONOMOUS" | |
| else | |
| log_error "✗ Orchestrator failed to start - check logs: $ORCHESTRATOR_LOG" | |
| rm -f "$ORCHESTRATOR_PID_FILE" | |
| exit 1 | |
| fi | |
| } | |
| # Show status | |
| show_status() { | |
| log_section "ECH0 EMPIRE STATUS" | |
| if is_running; then | |
| PID=$(cat "$ORCHESTRATOR_PID_FILE") | |
| log_info "✓ Master Orchestrator is RUNNING (PID: $PID)" | |
| # Calculate uptime | |
| if [ -f "$ORCHESTRATOR_PID_FILE" ]; then | |
| PID_FILE_TIME=$(stat -f %m "$ORCHESTRATOR_PID_FILE" 2>/dev/null || stat -c %Y "$ORCHESTRATOR_PID_FILE" 2>/dev/null) | |
| CURRENT_TIME=$(date +%s) | |
| UPTIME_SECONDS=$((CURRENT_TIME - PID_FILE_TIME)) | |
| UPTIME_HOURS=$((UPTIME_SECONDS / 3600)) | |
| UPTIME_DAYS=$((UPTIME_HOURS / 24)) | |
| if [ $UPTIME_DAYS -gt 0 ]; then | |
| log_info "Uptime: ${UPTIME_DAYS} days, $((UPTIME_HOURS % 24)) hours" | |
| else | |
| log_info "Uptime: ${UPTIME_HOURS} hours" | |
| fi | |
| fi | |
| # Show log tail | |
| log_info "" | |
| log_info "Recent logs (last 20 lines):" | |
| echo "────────────────────────────────────────────────────────────────" | |
| tail -n 20 "$ORCHESTRATOR_LOG" 2>/dev/null || echo "No logs available" | |
| echo "────────────────────────────────────────────────────────────────" | |
| # Run orchestrator status command | |
| log_info "" | |
| log_info "Agent Status:" | |
| python3 "$ORCHESTRATOR_SCRIPT" --status 2>/dev/null || log_warn "Could not retrieve detailed status" | |
| else | |
| log_warn "✗ Master Orchestrator is NOT RUNNING" | |
| log_info "Launch with: ./LAUNCH_ECH0_EMPIRE.sh" | |
| fi | |
| } | |
| # Shutdown orchestrator | |
| shutdown_orchestrator() { | |
| log_section "SHUTTING DOWN ECH0 EMPIRE" | |
| if ! is_running; then | |
| log_warn "Orchestrator is not running" | |
| return 0 | |
| fi | |
| PID=$(cat "$ORCHESTRATOR_PID_FILE") | |
| log_info "Sending graceful shutdown signal to PID $PID..." | |
| # Send SIGTERM for graceful shutdown | |
| kill -TERM "$PID" 2>/dev/null || { | |
| log_warn "Process $PID not found - cleaning up PID file" | |
| rm -f "$ORCHESTRATOR_PID_FILE" | |
| return 0 | |
| } | |
| # Wait for graceful shutdown (up to 30 seconds) | |
| log_info "Waiting for agents to shutdown gracefully..." | |
| for i in {1..30}; do | |
| if ! ps -p "$PID" > /dev/null 2>&1; then | |
| log_info "✓ Orchestrator stopped gracefully" | |
| rm -f "$ORCHESTRATOR_PID_FILE" | |
| return 0 | |
| fi | |
| sleep 1 | |
| echo -n "." | |
| done | |
| echo "" | |
| # Force kill if still running | |
| if ps -p "$PID" > /dev/null 2>&1; then | |
| log_warn "Graceful shutdown timeout - forcing termination" | |
| kill -KILL "$PID" 2>/dev/null | |
| sleep 2 | |
| fi | |
| rm -f "$ORCHESTRATOR_PID_FILE" | |
| log_info "✓ Shutdown complete" | |
| } | |
| # Install as system service (macOS LaunchAgent) | |
| install_service() { | |
| log_section "INSTALLING ECH0 AS SYSTEM SERVICE" | |
| if [[ "$OSTYPE" == "darwin"* ]]; then | |
| # macOS LaunchAgent | |
| PLIST_FILE="$HOME/Library/LaunchAgents/com.aios.ech0.plist" | |
| log_info "Creating LaunchAgent plist: $PLIST_FILE" | |
| cat > "$PLIST_FILE" <<EOF | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>com.aios.ech0</string> | |
| <key>ProgramArguments</key> | |
| <array> | |
| <string>/usr/bin/python3</string> | |
| <string>$ORCHESTRATOR_SCRIPT</string> | |
| <string>--launch-all</string> | |
| </array> | |
| <key>WorkingDirectory</key> | |
| <string>$ECH0_HOME</string> | |
| <key>StandardOutPath</key> | |
| <string>$ORCHESTRATOR_LOG</string> | |
| <key>StandardErrorPath</key> | |
| <string>$ORCHESTRATOR_LOG</string> | |
| <key>RunAtLoad</key> | |
| <true/> | |
| <key>KeepAlive</key> | |
| <dict> | |
| <key>SuccessfulExit</key> | |
| <false/> | |
| <key>Crashed</key> | |
| <true/> | |
| </dict> | |
| <key>ThrottleInterval</key> | |
| <integer>60</integer> | |
| <key>EnvironmentVariables</key> | |
| <dict> | |
| <key>PATH</key> | |
| <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string> | |
| </dict> | |
| </dict> | |
| </plist> | |
| EOF | |
| # Load the LaunchAgent | |
| launchctl unload "$PLIST_FILE" 2>/dev/null || true | |
| launchctl load "$PLIST_FILE" | |
| log_info "✓ ECH0 installed as LaunchAgent" | |
| log_info "✓ Will auto-start on login and auto-restart on crashes" | |
| log_info "" | |
| log_info "Management commands:" | |
| log_info " Start: launchctl start com.aios.ech0" | |
| log_info " Stop: launchctl stop com.aios.ech0" | |
| log_info " Restart: launchctl kickstart -k gui/$(id -u)/com.aios.ech0" | |
| log_info " Unload: launchctl unload $PLIST_FILE" | |
| elif [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
| # Linux systemd service | |
| SERVICE_FILE="/etc/systemd/system/ech0.service" | |
| log_info "Creating systemd service: $SERVICE_FILE" | |
| log_warn "This requires sudo privileges..." | |
| sudo tee "$SERVICE_FILE" > /dev/null <<EOF | |
| [Unit] | |
| Description=ECH0 Master Orchestrator - Autonomous Business Empire | |
| After=network.target | |
| [Service] | |
| Type=simple | |
| User=$USER | |
| WorkingDirectory=$ECH0_HOME | |
| ExecStart=/usr/bin/python3 $ORCHESTRATOR_SCRIPT --launch-all | |
| Restart=always | |
| RestartSec=60 | |
| StandardOutput=append:$ORCHESTRATOR_LOG | |
| StandardError=append:$ORCHESTRATOR_LOG | |
| [Install] | |
| WantedBy=multi-user.target | |
| EOF | |
| sudo systemctl daemon-reload | |
| sudo systemctl enable ech0.service | |
| sudo systemctl start ech0.service | |
| log_info "✓ ECH0 installed as systemd service" | |
| log_info "✓ Will auto-start on boot and auto-restart on crashes" | |
| log_info "" | |
| log_info "Management commands:" | |
| log_info " Status: sudo systemctl status ech0" | |
| log_info " Start: sudo systemctl start ech0" | |
| log_info " Stop: sudo systemctl stop ech0" | |
| log_info " Restart: sudo systemctl restart ech0" | |
| log_info " Logs: sudo journalctl -u ech0 -f" | |
| else | |
| log_error "Unsupported OS: $OSTYPE" | |
| log_info "Manual setup required for auto-start on boot" | |
| exit 1 | |
| fi | |
| } | |
| # Main command dispatcher | |
| main() { | |
| case "${1:-}" in | |
| --launch-all|--launch|"") | |
| launch_orchestrator | |
| ;; | |
| --status) | |
| show_status | |
| ;; | |
| --shutdown|--stop) | |
| shutdown_orchestrator | |
| ;; | |
| --install) | |
| install_service | |
| ;; | |
| --restart) | |
| shutdown_orchestrator | |
| sleep 3 | |
| launch_orchestrator | |
| ;; | |
| --help|-h) | |
| echo "ECH0 Empire Launch Script" | |
| echo "" | |
| echo "USAGE:" | |
| echo " ./LAUNCH_ECH0_EMPIRE.sh [COMMAND]" | |
| echo "" | |
| echo "COMMANDS:" | |
| echo " --launch-all Launch entire ECH0 empire (default)" | |
| echo " --status Show current system status" | |
| echo " --shutdown Gracefully shutdown all agents" | |
| echo " --restart Restart the orchestrator" | |
| echo " --install Install as system service (auto-start on boot)" | |
| echo " --help Show this help message" | |
| echo "" | |
| echo "EXAMPLES:" | |
| echo " ./LAUNCH_ECH0_EMPIRE.sh # Launch empire" | |
| echo " ./LAUNCH_ECH0_EMPIRE.sh --status # Check status" | |
| echo " ./LAUNCH_ECH0_EMPIRE.sh --install # Install service" | |
| echo "" | |
| echo "LOGS:" | |
| echo " tail -f $ORCHESTRATOR_LOG" | |
| ;; | |
| *) | |
| log_error "Unknown command: $1" | |
| log_info "Use --help for usage information" | |
| exit 1 | |
| ;; | |
| esac | |
| } | |
| main "$@" | |
Xet Storage Details
- Size:
- 12.6 kB
- Xet hash:
- 2edff2a4ab4a316e6e46e8b7193461f5f5c60e2d40865f7a8fba3ca930c22822
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.