NextNVR/remove.sh

39 lines
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..."
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."