mirror of
https://github.com/myronblair/jarvis
synced 2026-06-30 17:50:23 -05:00
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
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
#!/bin/bash
|
||||
# JARVIS Agent Installer
|
||||
# Usage: curl -sSL https://raw.githubusercontent.com/myronblair/jarvis/master/agent/install.sh | sudo bash
|
||||
# Or: sudo bash install.sh --jarvis-url https://jarvis.orbishosting.com --key YOUR_REGISTRATION_KEY
|
||||
|
||||
set -e
|
||||
|
||||
JARVIS_URL=""
|
||||
REG_KEY=""
|
||||
AGENT_TYPE="linux"
|
||||
INSTALL_DIR="/opt/jarvis-agent"
|
||||
CONFIG_DIR="/etc/jarvis-agent"
|
||||
STATE_DIR="/var/lib/jarvis-agent"
|
||||
SERVICE_NAME="jarvis-agent"
|
||||
|
||||
# ── Parse args ────────────────────────────────────────────────────────────────
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--jarvis-url) JARVIS_URL="$2"; shift 2 ;;
|
||||
--key) REG_KEY="$2"; shift 2 ;;
|
||||
--type) AGENT_TYPE="$2"; shift 2 ;;
|
||||
*) echo "Unknown arg: $1"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# ── Interactive prompts if not provided ──────────────────────────────────────
|
||||
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%/}"
|
||||
|
||||
echo ""
|
||||
echo "Installing JARVIS Agent..."
|
||||
echo " URL: $JARVIS_URL"
|
||||
echo " Type: $AGENT_TYPE"
|
||||
echo ""
|
||||
|
||||
# ── Install Python3 if needed ─────────────────────────────────────────────────
|
||||
if ! command -v python3 &>/dev/null; then
|
||||
echo "Installing python3..."
|
||||
apt-get update -qq && apt-get install -y python3 || yum install -y python3 || dnf install -y python3
|
||||
fi
|
||||
|
||||
# ── Create directories ────────────────────────────────────────────────────────
|
||||
mkdir -p "$INSTALL_DIR" "$CONFIG_DIR" "$STATE_DIR"
|
||||
|
||||
# ── 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 script..."
|
||||
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"
|
||||
|
||||
# ── Write config ──────────────────────────────────────────────────────────────
|
||||
HOSTNAME=$(hostname -f 2>/dev/null || hostname)
|
||||
|
||||
if [[ -f "$CONFIG_DIR/config.json" ]]; then
|
||||
echo "Config already exists at $CONFIG_DIR/config.json — skipping (keeping existing settings)."
|
||||
else
|
||||
cat > "$CONFIG_DIR/config.json" << JSONEOF
|
||||
{
|
||||
"jarvis_url": "$JARVIS_URL",
|
||||
"registration_key": "$REG_KEY",
|
||||
"hostname": "$HOSTNAME",
|
||||
"agent_type": "$AGENT_TYPE",
|
||||
"poll_interval": 30,
|
||||
"heartbeat_every": 10,
|
||||
"watch_services": ["ollama", "homeassistant", "mysql", "mariadb", "nginx", "apache2", "docker"]
|
||||
}
|
||||
JSONEOF
|
||||
chmod 600 "$CONFIG_DIR/config.json"
|
||||
echo "Config written to $CONFIG_DIR/config.json"
|
||||
fi
|
||||
|
||||
# ── Write systemd service ─────────────────────────────────────────────────────
|
||||
cat > "/etc/systemd/system/${SERVICE_NAME}.service" << SVCEOF
|
||||
[Unit]
|
||||
Description=JARVIS Monitoring Agent
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/python3 $INSTALL_DIR/jarvis-agent.py
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
SVCEOF
|
||||
|
||||
# ── Enable and start ──────────────────────────────────────────────────────────
|
||||
systemctl daemon-reload
|
||||
systemctl enable "$SERVICE_NAME"
|
||||
systemctl restart "$SERVICE_NAME"
|
||||
|
||||
sleep 2
|
||||
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||
echo ""
|
||||
echo "✓ JARVIS Agent installed and running."
|
||||
echo " View logs: journalctl -u $SERVICE_NAME -f"
|
||||
echo " Config: $CONFIG_DIR/config.json"
|
||||
else
|
||||
echo ""
|
||||
echo "⚠ Agent installed but not running. Check logs:"
|
||||
echo " journalctl -u $SERVICE_NAME -n 30"
|
||||
fi
|
||||
Reference in New Issue
Block a user