mirror of
https://github.com/myronblair/jarvis
synced 2026-07-28 08:43:00 -05:00
Agent v3.1/3.0 — Mac agent, Windows self-update, all capabilities parity
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
#!/bin/bash
|
||||
# JARVIS Agent Installer — macOS
|
||||
# Usage: bash install-mac.sh --jarvis-url https://jarvis.orbishosting.com --key YOUR_KEY
|
||||
# Or one-liner: bash <(curl -sSL https://jarvis.orbishosting.com/agent/install-mac.sh) --key YOUR_KEY
|
||||
|
||||
set -e
|
||||
|
||||
JARVIS_URL=""
|
||||
JARVIS_URL="https://jarvis.orbishosting.com"
|
||||
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"
|
||||
|
||||
@@ -19,59 +19,67 @@ while [[ $# -gt 0 ]]; do
|
||||
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%/}"
|
||||
|
||||
echo ""
|
||||
echo " ===================================="
|
||||
echo " JARVIS Agent Installer v3.0 "
|
||||
echo " ===================================="
|
||||
echo ""
|
||||
|
||||
# Check for Python3
|
||||
PYTHON3=$(command -v python3 2>/dev/null || command -v /usr/bin/python3 2>/dev/null || "")
|
||||
PYTHON3=$(command -v 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))"
|
||||
echo "Using Python: $PYTHON3 ($($PYTHON3 --version 2>&1))"
|
||||
|
||||
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"
|
||||
# Download macOS-native agent script
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd || echo "")"
|
||||
if [[ -f "$SCRIPT_DIR/jarvis-agent-mac.py" ]]; then
|
||||
cp "$SCRIPT_DIR/jarvis-agent-mac.py" "$INSTALL_DIR/jarvis-agent.py"
|
||||
echo "Copied agent from local directory."
|
||||
else
|
||||
echo "Downloading agent..."
|
||||
curl -sSL "https://raw.githubusercontent.com/myronblair/jarvis/master/agent/jarvis-agent.py" \
|
||||
-o "$INSTALL_DIR/jarvis-agent.py"
|
||||
echo "Downloading macOS agent..."
|
||||
curl -sSL "$JARVIS_URL/agent/jarvis-agent-mac.py" -o "$INSTALL_DIR/jarvis-agent.py"
|
||||
echo "Downloaded."
|
||||
fi
|
||||
chmod +x "$INSTALL_DIR/jarvis-agent.py"
|
||||
|
||||
HOSTNAME=$(hostname -f 2>/dev/null || hostname)
|
||||
AGENT_ID="${HOSTNAME}_mac"
|
||||
|
||||
# Write config
|
||||
if [[ ! -f "$CONFIG_DIR/config.json" ]]; then
|
||||
cat > "$CONFIG_DIR/config.json" << JSONEOF
|
||||
# Write config (preserve existing)
|
||||
if [[ ! -f "$INSTALL_DIR/config.json" ]]; then
|
||||
cat > "$INSTALL_DIR/config.json" << JSONEOF
|
||||
{
|
||||
"jarvis_url": "$JARVIS_URL",
|
||||
"registration_key": "$REG_KEY",
|
||||
"hostname": "$HOSTNAME",
|
||||
"agent_type": "linux",
|
||||
"agent_id": "$AGENT_ID",
|
||||
"agent_type": "macos",
|
||||
"poll_interval": 30,
|
||||
"heartbeat_every": 10,
|
||||
"watch_services": []
|
||||
"update_check_hours": 24,
|
||||
"watch_services": [],
|
||||
"allow_shell_commands": false
|
||||
}
|
||||
JSONEOF
|
||||
chmod 600 "$CONFIG_DIR/config.json"
|
||||
chmod 600 "$INSTALL_DIR/config.json"
|
||||
echo "Config written to $INSTALL_DIR/config.json"
|
||||
else
|
||||
echo "Config already exists — preserving $INSTALL_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
|
||||
@@ -89,9 +97,9 @@ cat > "$PLIST_PATH" << PLISTEOF
|
||||
<key>EnvironmentVariables</key>
|
||||
<dict>
|
||||
<key>JARVIS_CONFIG</key>
|
||||
<string>$CONFIG_DIR/config.json</string>
|
||||
<string>$INSTALL_DIR/config.json</string>
|
||||
<key>JARVIS_STATE</key>
|
||||
<string>$STATE_PATH</string>
|
||||
<string>$INSTALL_DIR/state.json</string>
|
||||
</dict>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
@@ -105,18 +113,23 @@ cat > "$PLIST_PATH" << PLISTEOF
|
||||
</plist>
|
||||
PLISTEOF
|
||||
|
||||
# Load the service
|
||||
# Load/reload the service
|
||||
launchctl unload "$PLIST_PATH" 2>/dev/null || true
|
||||
launchctl load "$PLIST_PATH"
|
||||
|
||||
sleep 2
|
||||
if launchctl list | grep -q "$SERVICE_LABEL"; then
|
||||
if launchctl list 2>/dev/null | 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"
|
||||
echo " JARVIS Agent installed and running."
|
||||
echo " Machine : $HOSTNAME ($AGENT_ID)"
|
||||
echo " JARVIS : $JARVIS_URL"
|
||||
echo " Logs : tail -f $INSTALL_DIR/jarvis-agent.log"
|
||||
echo " Config : $INSTALL_DIR/config.json"
|
||||
echo " Stop : launchctl unload $PLIST_PATH"
|
||||
echo " Update : curl -sSL $JARVIS_URL/agent/install-mac.sh | bash -s -- --key $REG_KEY"
|
||||
else
|
||||
echo "⚠ Agent installed but not running. Check logs:"
|
||||
echo ""
|
||||
echo " Agent installed but not detected as running. Check logs:"
|
||||
echo " tail -f $INSTALL_DIR/jarvis-agent.log"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user