uninstall.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. set -e
  3. echo "======================================"
  4. echo "Webshop Scraper Uninstallation Script"
  5. echo "======================================"
  6. echo ""
  7. # Check if running as root
  8. if [ "$EUID" -ne 0 ]; then
  9. echo "Error: Please run as root (use sudo)"
  10. exit 1
  11. fi
  12. INSTALL_DIR="/opt/webshop-scraper"
  13. SERVICE_NAME="webshop-scraper"
  14. # Confirm uninstallation
  15. echo "This will remove the Webshop Scraper service and all its files."
  16. echo "Are you sure you want to continue? (y/N)"
  17. read -r CONFIRM
  18. if [ "$CONFIRM" != "y" ] && [ "$CONFIRM" != "Y" ]; then
  19. echo "Uninstallation cancelled."
  20. exit 0
  21. fi
  22. echo ""
  23. echo "Uninstalling Webshop Scraper..."
  24. echo ""
  25. # Stop service if running
  26. if systemctl is-active --quiet "$SERVICE_NAME"; then
  27. echo "Stopping service..."
  28. systemctl stop "$SERVICE_NAME"
  29. fi
  30. # Disable service
  31. if systemctl is-enabled --quiet "$SERVICE_NAME" 2>/dev/null; then
  32. echo "Disabling service..."
  33. systemctl disable "$SERVICE_NAME"
  34. fi
  35. # Remove systemd service file
  36. if [ -f "/etc/systemd/system/$SERVICE_NAME.service" ]; then
  37. echo "Removing systemd service file..."
  38. rm -f "/etc/systemd/system/$SERVICE_NAME.service"
  39. fi
  40. # Reload systemd
  41. echo "Reloading systemd..."
  42. systemctl daemon-reload
  43. # Remove installation directory
  44. if [ -d "$INSTALL_DIR" ]; then
  45. echo "Removing installation directory..."
  46. rm -rf "$INSTALL_DIR"
  47. fi
  48. echo ""
  49. echo "======================================"
  50. echo "Uninstallation completed successfully!"
  51. echo "======================================"
  52. echo ""