#!/usr/bin/env bash # Install / update the vmwatch fishtank service on the Proxmox host. # # What this puts on spicy (and nothing else -- no packages, no pip): # /opt/vmwatch/vmwatch.py the service (Python 3 stdlib only) # /etc/systemd/system/vmwatch.service # # Usage: tools/vmwatch-install.sh [host] (default host: spicy) # tools/vmwatch-install.sh spicy --uninstall set -euo pipefail HOST="${1:-spicy}" SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/vmwatch.py" PORT="${VMWATCH_PORT:-8140}" INTERVAL="${VMWATCH_INTERVAL:-5}" if [[ "${2:-}" == "--uninstall" ]]; then ssh "$HOST" 'systemctl disable --now vmwatch.service 2>/dev/null || true rm -f /etc/systemd/system/vmwatch.service rm -rf /opt/vmwatch systemctl daemon-reload echo "vmwatch removed from $(hostname)"' exit 0 fi echo "installing vmwatch on $HOST (port $PORT, interval ${INTERVAL}s)" ssh "$HOST" "mkdir -p /opt/vmwatch" scp -q "$SRC" "$HOST:/opt/vmwatch/vmwatch.py" ssh "$HOST" "chmod 0755 /opt/vmwatch/vmwatch.py" ssh "$HOST" "cat > /etc/systemd/system/vmwatch.service" </dev/null \ && systemctl restart vmwatch.service && sleep 2 && systemctl is-active vmwatch.service" IP=$(ssh "$HOST" "hostname -I | tr ' ' '\n' | grep -E '^192\.168\.' | head -1") echo echo "http://${IP}:${PORT}/"