mirror of
https://github.com/myronblair/jarvis
synced 2026-07-28 00:34:35 -05:00
a292411d52
The installer wrote the same service list (ollama, homeassistant, mysql, mariadb, nginx, apache2, docker) onto every host regardless of what it actually runs, causing false "Service Down" alerts on hosts that never installed those services. Default is now empty; watch_services should be set per-host to match what's actually running there.
99 lines
4.0 KiB
Bash
Executable File
99 lines
4.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# JARVIS Agent Installer — one-liner for any Linux host:
|
|
# curl -sk https://jarvis.orbishosting.com/install-agent.sh | bash -s <hostname> <agent_type>
|
|
#
|
|
# 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="https://165.22.1.228"
|
|
JARVIS_HOST="jarvis.orbishosting.com"
|
|
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 -H "Host: $JARVIS_HOST" "$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": false,
|
|
"registration_key": "$REG_KEY",
|
|
"hostname": "$HOSTNAME_ARG",
|
|
"agent_type": "$AGENT_TYPE",
|
|
"poll_interval": 30,
|
|
"heartbeat_every": 10,
|
|
"update_check_hours": 24,
|
|
"watch_services": []
|
|
}
|
|
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
|