diff --git a/remove.sh b/remove.sh new file mode 100755 index 0000000..1691324 --- /dev/null +++ b/remove.sh @@ -0,0 +1,39 @@ +#!/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..." +sudo systemctl stop "${SERVICE_NAME}" 2>/dev/null || true +sudo systemctl disable "${SERVICE_NAME}" 2>/dev/null || true + +# Kill any lingering processes. +echo "Killing processes..." +sudo pkill -9 -f "nextnvr" 2>/dev/null || true +sudo pkill -9 -f "go2rtc" 2>/dev/null || true +sudo pkill -9 -f "ffmpeg.*rec_" 2>/dev/null || true +sleep 1 + +# Remove systemd service file. +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."