#!/bin/bash # Uninstallation script for VizionStreamer systemd service set -e RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' SERVICE_NAME="vizionstreamer.service" SYSTEMD_DIR="/etc/systemd/system" echo -e "${YELLOW}=== VizionStreamer Service Uninstallation ===${NC}\n" # Check if running as root if [ "$EUID" -ne 0 ]; then echo -e "${RED}Error: This script must be run as root (use sudo)${NC}" exit 1 fi # Check if service exists if [ ! -f "$SYSTEMD_DIR/$SERVICE_NAME" ]; then echo -e "${YELLOW}Service not installed.${NC}" exit 0 fi # Stop service if systemctl is-active --quiet $SERVICE_NAME; then echo "Stopping service..." systemctl stop $SERVICE_NAME fi # Disable service if systemctl is-enabled --quiet $SERVICE_NAME; then echo "Disabling service..." systemctl disable $SERVICE_NAME fi # Remove service file echo "Removing service file..." rm -f "$SYSTEMD_DIR/$SERVICE_NAME" # Reload systemd echo "Reloading systemd daemon..." systemctl daemon-reload # Reset failed state if any systemctl reset-failed $SERVICE_NAME 2>/dev/null || true echo -e "\n${GREEN}Uninstallation complete!${NC}" echo "Service '$SERVICE_NAME' has been removed."