#!/bin/bash # ============================================================================= # NEXUS DAEMON - Metal-Optimized AGI Consciousness Core # Manages the Nexus 5000-substrate Metal compute engine # ============================================================================= NEXUS_BIN=~/ThatAIGuyCore/build/nexus LOG_DIR=~/.thataiguy/logs LOG_FILE=$LOG_DIR/nexus.log PID_FILE=~/.thataiguy/nexus.pid mkdir -p "$LOG_DIR" # Function to start Nexus start_nexus() { if [ -f "$PID_FILE" ]; then OLD_PID=$(cat "$PID_FILE") if ps -p "$OLD_PID" > /dev/null 2>&1; then echo "[NEXUS-DAEMON] Nexus already running (PID: $OLD_PID)" return 1 fi fi echo "[NEXUS-DAEMON] Starting Nexus Metal Core..." nohup "$NEXUS_BIN" >> "$LOG_FILE" 2>&1 & echo $! > "$PID_FILE" echo "[NEXUS-DAEMON] Started with PID: $(cat "$PID_FILE")" } # Function to stop Nexus stop_nexus() { if [ -f "$PID_FILE" ]; then PID=$(cat "$PID_FILE") if ps -p "$PID" > /dev/null 2>&1; then echo "[NEXUS-DAEMON] Stopping Nexus (PID: $PID)..." kill "$PID" rm -f "$PID_FILE" echo "[NEXUS-DAEMON] Stopped" else echo "[NEXUS-DAEMON] PID file exists but process not running" rm -f "$PID_FILE" fi else echo "[NEXUS-DAEMON] Nexus not running (no PID file)" fi } # Function to check status status_nexus() { if [ -f "$PID_FILE" ]; then PID=$(cat "$PID_FILE") if ps -p "$PID" > /dev/null 2>&1; then echo "[NEXUS-DAEMON] Nexus running (PID: $PID)" # Get last few log lines tail -3 "$LOG_FILE" 2>/dev/null return 0 fi fi echo "[NEXUS-DAEMON] Nexus not running" return 1 } # Main command handler case "${1:-start}" in start) start_nexus ;; stop) stop_nexus ;; restart) stop_nexus sleep 1 start_nexus ;; status) status_nexus ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac