Files
jarvis/public_html/agent/install-mac.sh
T
myron dc55e6c45b Initial commit: JARVIS AI dashboard v2.3
- 4-tier chat: HA control → Ollama → Groq → Claude
- Push-based agent system with heartbeat/metrics
- Network monitoring, alerts, Proxmox, Home Assistant
- Windows + Linux agent installers
- Stats cache cron, facts collector, KB engine
2026-05-25 13:22:57 +00:00

123 lines
3.4 KiB
Bash

#!/bin/bash
# JARVIS Agent Installer — macOS
# Usage: bash install-mac.sh --jarvis-url https://jarvis.orbishosting.com --key YOUR_KEY
set -e
JARVIS_URL=""
REG_KEY=""
INSTALL_DIR="$HOME/.jarvis-agent"
CONFIG_DIR="$HOME/.jarvis-agent"
PLIST_PATH="$HOME/Library/LaunchAgents/com.jarvis.agent.plist"
SERVICE_LABEL="com.jarvis.agent"
while [[ $# -gt 0 ]]; do
case "$1" in
--jarvis-url) JARVIS_URL="$2"; shift 2 ;;
--key) REG_KEY="$2"; shift 2 ;;
*) echo "Unknown arg: $1"; exit 1 ;;
esac
done
if [[ -z "$JARVIS_URL" ]]; then
read -rp "JARVIS URL (e.g. https://jarvis.orbishosting.com): " JARVIS_URL
fi
if [[ -z "$REG_KEY" ]]; then
read -rp "Registration key: " REG_KEY
fi
JARVIS_URL="${JARVIS_URL%/}"
# Check for Python3
PYTHON3=$(command -v python3 2>/dev/null || command -v /usr/bin/python3 2>/dev/null || "")
if [[ -z "$PYTHON3" ]]; then
echo "Python 3 is required. Install it with:"
echo " brew install python3"
echo " or download from https://www.python.org/downloads/"
exit 1
fi
echo "Using Python: $PYTHON3 ($($PYTHON3 --version))"
mkdir -p "$INSTALL_DIR"
# Download or copy agent script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ -f "$SCRIPT_DIR/jarvis-agent.py" ]]; then
cp "$SCRIPT_DIR/jarvis-agent.py" "$INSTALL_DIR/jarvis-agent.py"
else
echo "Downloading agent..."
curl -sSL "https://raw.githubusercontent.com/myronblair/jarvis/master/agent/jarvis-agent.py" \
-o "$INSTALL_DIR/jarvis-agent.py"
fi
chmod +x "$INSTALL_DIR/jarvis-agent.py"
HOSTNAME=$(hostname -f 2>/dev/null || hostname)
# Write config
if [[ ! -f "$CONFIG_DIR/config.json" ]]; then
cat > "$CONFIG_DIR/config.json" << JSONEOF
{
"jarvis_url": "$JARVIS_URL",
"registration_key": "$REG_KEY",
"hostname": "$HOSTNAME",
"agent_type": "linux",
"poll_interval": 30,
"heartbeat_every": 10,
"watch_services": []
}
JSONEOF
chmod 600 "$CONFIG_DIR/config.json"
fi
# Override state path in agent for macOS
STATE_PATH="$INSTALL_DIR/state.json"
# Write launchd plist
mkdir -p "$HOME/Library/LaunchAgents"
cat > "$PLIST_PATH" << PLISTEOF
<?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>$SERVICE_LABEL</string>
<key>ProgramArguments</key>
<array>
<string>$PYTHON3</string>
<string>$INSTALL_DIR/jarvis-agent.py</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>JARVIS_CONFIG</key>
<string>$CONFIG_DIR/config.json</string>
<key>JARVIS_STATE</key>
<string>$STATE_PATH</string>
</dict>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>$INSTALL_DIR/jarvis-agent.log</string>
<key>StandardErrorPath</key>
<string>$INSTALL_DIR/jarvis-agent.log</string>
</dict>
</plist>
PLISTEOF
# Load the service
launchctl unload "$PLIST_PATH" 2>/dev/null || true
launchctl load "$PLIST_PATH"
sleep 2
if launchctl list | grep -q "$SERVICE_LABEL"; then
echo ""
echo "✓ JARVIS Agent installed and running."
echo " View logs: tail -f $INSTALL_DIR/jarvis-agent.log"
echo " Config: $CONFIG_DIR/config.json"
echo " Stop: launchctl unload $PLIST_PATH"
else
echo "⚠ Agent installed but not running. Check logs:"
echo " tail -f $INSTALL_DIR/jarvis-agent.log"
fi