NextNVR/remove.sh

43 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
# NextNVR — Clean Removal Script
# Removes all traces for a greenfield redeployment.
# Usage: ./remove.sh
SERVICE_NAME="nextnvr"
DEPLOY_DIR="/opt/nextnvr"
echo "=== NextNVR Clean Removal ==="
echo ""
# Stop service.
echo "Stopping service..."
if systemctl is-active --quiet "${SERVICE_NAME}" 2>/dev/null; then
sudo systemctl stop "${SERVICE_NAME}" 2>/dev/null || true
sleep 2
fi
# Kill remaining processes by PID (targeted).
for proc in "/opt/nextnvr/nextnvr" "go2rtc"; do
for pid in $(pgrep -f "${proc}" 2>/dev/null || true); do
sudo kill "${pid}" 2>/dev/null || true
done
done
sleep 1
# Remove systemd service.
sudo systemctl disable "${SERVICE_NAME}" 2>/dev/null || true
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
sudo rm -f "/etc/systemd/system/${SERVICE_NAME}.service"
sudo systemctl daemon-reload
echo "Service file removed."
fi
# Remove deployment directory.
if [ -d "${DEPLOY_DIR}" ]; then
sudo rm -rf "${DEPLOY_DIR}"
echo "Removed ${DEPLOY_DIR}"
fi
echo ""
echo "NextNVR removed. Recordings at /mnt/recordings are untouched."
echo "Run ./deploy_nvr.sh for a fresh install."