scripts/uninstall.sh — clean removal of fireclaw: - Stops all agents and overseer - Removes bridge, taps, iptables rules - Removes ~/.fireclaw data directory - Unlinks global command - Optionally removes deps (--keep-deps to preserve them) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
135 lines
5.4 KiB
Bash
Executable File
135 lines
5.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Fireclaw uninstall script
|
|
# Stops all services, removes all fireclaw data, and optionally removes dependencies.
|
|
#
|
|
# Usage: ./scripts/uninstall.sh [--keep-deps]
|
|
# --keep-deps Keep system packages (firecracker, ollama, ngircd, node)
|
|
|
|
set -euo pipefail
|
|
|
|
KEEP_DEPS=false
|
|
[[ "${1:-}" == "--keep-deps" ]] && KEEP_DEPS=true
|
|
|
|
log() { echo -e "\033[1;34m[fireclaw]\033[0m $*"; }
|
|
warn() { echo -e "\033[1;33m[warn]\033[0m $*"; }
|
|
|
|
FIRECLAW_DIR="$HOME/.fireclaw"
|
|
|
|
# ─── Stop agents ──────────────────────────────────────────────────────
|
|
|
|
log "Stopping all agents..."
|
|
if command -v fireclaw &>/dev/null; then
|
|
# Get list of running agents and stop them
|
|
if [[ -f "$FIRECLAW_DIR/agents.json" ]]; then
|
|
for name in $(python3 -c "import json; [print(k) for k in json.load(open('$FIRECLAW_DIR/agents.json'))]" 2>/dev/null); do
|
|
log " Stopping agent: $name"
|
|
fireclaw agent stop "$name" 2>/dev/null || true
|
|
done
|
|
fi
|
|
fi
|
|
|
|
# Kill any remaining firecracker processes
|
|
pkill -f "firecracker --api-sock /tmp/fireclaw/" 2>/dev/null || true
|
|
sleep 1
|
|
|
|
# ─── Stop services ───────────────────────────────────────────────────
|
|
|
|
log "Stopping services..."
|
|
|
|
if systemctl is-active fireclaw-overseer &>/dev/null; then
|
|
sudo systemctl stop fireclaw-overseer
|
|
sudo systemctl disable fireclaw-overseer 2>/dev/null || true
|
|
fi
|
|
sudo rm -f /etc/systemd/system/fireclaw-overseer.service
|
|
|
|
# ─── Network cleanup ─────────────────────────────────────────────────
|
|
|
|
log "Cleaning up network..."
|
|
|
|
# Remove all fireclaw tap devices
|
|
for tap in $(ip link show 2>/dev/null | grep -oP 'fctap\d+' | sort -u); do
|
|
sudo ip tuntap del "$tap" mode tap 2>/dev/null || true
|
|
done
|
|
|
|
# Remove bridge
|
|
if ip link show fcbr0 &>/dev/null; then
|
|
# Remove iptables rules
|
|
SUBNET="172.16.0.0/24"
|
|
EXT_IFACE=$(ip route show default | awk '{print $5; exit}')
|
|
sudo iptables -t nat -D POSTROUTING -s "${SUBNET}" -o "${EXT_IFACE}" -j MASQUERADE 2>/dev/null || true
|
|
sudo iptables -D FORWARD -i fcbr0 -o "${EXT_IFACE}" -j ACCEPT 2>/dev/null || true
|
|
sudo iptables -D FORWARD -i "${EXT_IFACE}" -o fcbr0 -m state --state RELATED,ESTABLISHED -j ACCEPT 2>/dev/null || true
|
|
# Remove any per-agent DROP/ACCEPT rules
|
|
for _ in $(seq 1 20); do
|
|
sudo iptables -D FORWARD -j DROP 2>/dev/null || break
|
|
done
|
|
for _ in $(seq 1 20); do
|
|
sudo iptables -D FORWARD -j ACCEPT 2>/dev/null || break
|
|
done
|
|
sudo ip link set fcbr0 down 2>/dev/null || true
|
|
sudo ip link del fcbr0 2>/dev/null || true
|
|
log " Bridge fcbr0 removed"
|
|
fi
|
|
|
|
# ─── Remove fireclaw data ────────────────────────────────────────────
|
|
|
|
log "Removing fireclaw data..."
|
|
rm -rf "$FIRECLAW_DIR"
|
|
rm -rf /tmp/fireclaw/
|
|
log " Removed $FIRECLAW_DIR"
|
|
|
|
# ─── Unlink global command ───────────────────────────────────────────
|
|
|
|
if command -v fireclaw &>/dev/null; then
|
|
log "Removing global fireclaw command..."
|
|
sudo npm unlink -g fireclaw 2>/dev/null || sudo rm -f /usr/local/bin/fireclaw
|
|
fi
|
|
|
|
# ─── Remove dependencies (optional) ──────────────────────────────────
|
|
|
|
if ! $KEEP_DEPS; then
|
|
log "Removing dependencies..."
|
|
|
|
# Ollama
|
|
if systemctl is-active ollama &>/dev/null; then
|
|
sudo systemctl stop ollama
|
|
sudo systemctl disable ollama 2>/dev/null || true
|
|
fi
|
|
sudo rm -f /etc/systemd/system/ollama.service
|
|
sudo rm -f /usr/local/bin/ollama
|
|
rm -rf "$HOME/.ollama" 2>/dev/null || true
|
|
log " Ollama removed"
|
|
|
|
# Firecracker
|
|
sudo rm -f /usr/local/bin/firecracker /usr/local/bin/jailer
|
|
log " Firecracker removed"
|
|
|
|
# ngircd — restore default config
|
|
if [[ -f /etc/ngircd/ngircd.conf.bak ]]; then
|
|
sudo cp /etc/ngircd/ngircd.conf.bak /etc/ngircd/ngircd.conf
|
|
sudo systemctl restart ngircd 2>/dev/null || true
|
|
log " ngircd config restored from backup"
|
|
fi
|
|
|
|
sudo systemctl daemon-reload
|
|
else
|
|
warn "Keeping dependencies (firecracker, ollama, ngircd). Use without --keep-deps to remove them."
|
|
fi
|
|
|
|
# ─── Done ─────────────────────────────────────────────────────────────
|
|
|
|
echo ""
|
|
log "═══════════════════════════════════════════════"
|
|
log " Fireclaw uninstalled."
|
|
log "═══════════════════════════════════════════════"
|
|
log ""
|
|
log " The project source code at $(pwd) was NOT removed."
|
|
log " Remove it manually if you want: rm -rf $(pwd)"
|
|
log ""
|
|
if ! $KEEP_DEPS; then
|
|
log " Dependencies removed: firecracker, ollama, ngircd config"
|
|
else
|
|
log " Dependencies kept: firecracker, ollama, ngircd"
|
|
fi
|
|
log "═══════════════════════════════════════════════"
|