#!/bin/bash set -e echo "======================================" echo "Web Scraper Uninstallation Script" echo "======================================" echo "" # Check if running as root if [ "$EUID" -ne 0 ]; then echo "Error: Please run as root (use sudo)" exit 1 fi INSTALL_DIR="/opt/webshop-scraper" SERVICE_NAME="webshop-scraper" # Confirm uninstallation echo "This will remove the Web Scraper service and all its files." echo "Are you sure you want to continue? (y/N)" read -r CONFIRM if [ "$CONFIRM" != "y" ] && [ "$CONFIRM" != "Y" ]; then echo "Uninstallation cancelled." exit 0 fi echo "" echo "Uninstalling Web Scraper..." echo "" # Stop service if running 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" 2>/dev/null; then echo "Disabling service..." systemctl disable "$SERVICE_NAME" fi # Remove systemd service file if [ -f "/etc/systemd/system/$SERVICE_NAME.service" ]; then echo "Removing systemd service file..." rm -f "/etc/systemd/system/$SERVICE_NAME.service" fi # Reload systemd echo "Reloading systemd..." systemctl daemon-reload # Remove installation directory if [ -d "$INSTALL_DIR" ]; then echo "Removing installation directory..." rm -rf "$INSTALL_DIR" fi echo "" echo "======================================" echo "Uninstallation completed successfully!" echo "======================================" echo ""