#!/bin/bash # JARVIS Agent Installer — one-liner for any Linux host: # curl -sk https://jarvis.orbishosting.com/install-agent.sh | bash -s # # agent_type: linux | proxmox | homeassistant # Example: curl -sk https://jarvis.orbishosting.com/install-agent.sh | bash -s myserver linux set -e HOSTNAME_ARG="${1:-$(hostname -s)}" AGENT_TYPE="${2:-linux}" JARVIS_URL="${JARVIS_URL:-https://jarvis.orbishosting.com}" JARVIS_HOST="" INSTALL_DIR="/opt/jarvis-agent" CONFIG_DIR="/etc/jarvis-agent" STATE_DIR="/var/lib/jarvis-agent" REG_KEY="f846a9aaf7ce9a61742c63c87c4186052a71d2a580c65518" SERVICE_FILE="/etc/systemd/system/jarvis-agent.service" echo "=== JARVIS Agent Installer v3.0 ===" echo "Host: $HOSTNAME_ARG | Type: $AGENT_TYPE | Server: $JARVIS_URL" # ── Dependencies ────────────────────────────────────────────────────────────── if command -v apt-get &>/dev/null; then apt-get install -yq python3 curl imagemagick 2>/dev/null || true apt-get install -yq python3-psutil python3-requests 2>/dev/null || true elif command -v yum &>/dev/null; then yum install -yq python3 curl ImageMagick 2>/dev/null || true elif command -v apk &>/dev/null; then apk add --no-cache python3 curl imagemagick 2>/dev/null || true fi # pip fallback if psutil/requests not available via package manager python3 -c "import psutil, requests" 2>/dev/null || pip3 install -q --break-system-packages requests psutil 2>/dev/null || pip3 install -q requests psutil 2>/dev/null || true # ── Create directories ───────────────────────────────────────────────────────── mkdir -p "$INSTALL_DIR" "$CONFIG_DIR" "$STATE_DIR" # ── Download agent ───────────────────────────────────────────────────────────── echo "Downloading agent..." curl -sk "$JARVIS_URL/agent/jarvis-agent.py" -o "$INSTALL_DIR/jarvis-agent.py" cp "$INSTALL_DIR/jarvis-agent.py" /usr/local/bin/jarvis-agent.py chmod +x "$INSTALL_DIR/jarvis-agent.py" /usr/local/bin/jarvis-agent.py # ── Write config (skip if already exists) ──────────────────────────────────── if [[ -f "$CONFIG_DIR/config.json" ]]; then echo "Config already exists at $CONFIG_DIR/config.json — keeping existing settings." else cat > "$CONFIG_DIR/config.json" << JSONEOF { "jarvis_url": "$JARVIS_URL", "host_header": "$JARVIS_HOST", "ssl_verify": true, "registration_key": "$REG_KEY", "hostname": "$HOSTNAME_ARG", "agent_type": "$AGENT_TYPE", "poll_interval": 30, "heartbeat_every": 10, "update_check_hours": 24, "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 # ── Systemd service ──────────────────────────────────────────────────────────── cat > "$SERVICE_FILE" << SVCEOF [Unit] Description=JARVIS 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 [Install] WantedBy=multi-user.target SVCEOF systemctl daemon-reload systemctl enable jarvis-agent systemctl restart jarvis-agent sleep 2 if systemctl is-active --quiet jarvis-agent; then echo "" echo "=== JARVIS Agent v3.0 installed and running ===" echo "Config: $CONFIG_DIR/config.json" echo "State: $STATE_DIR/state.json (created on first run)" echo "Logs: journalctl -u jarvis-agent -f" else echo "" echo "WARNING: Agent installed but not running. Check: journalctl -u jarvis-agent -n 30" fi