uninstall.sh 1023 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. # filepath: /home/setyotontowi/BackendProject/gogsmilestone/uninstall.sh
  3. # Dynamically determine the project directory
  4. PROJECT_DIR=$(dirname "$(realpath "$0")")
  5. echo "Uninstalling the project from $PROJECT_DIR..."
  6. # Step 1: Stop and disable the systemd service
  7. SERVICE_FILE="/etc/systemd/system/gogmilestone.service"
  8. if [ -f "$SERVICE_FILE" ]; then
  9. echo "Stopping the gogmilestone service..."
  10. sudo systemctl stop gogmilestone
  11. echo "Disabling the gogmilestone service..."
  12. sudo systemctl disable gogmilestone
  13. echo "Removing the gogmilestone service file..."
  14. sudo rm -f "$SERVICE_FILE"
  15. echo "Reloading systemd daemon..."
  16. sudo systemctl daemon-reload
  17. else
  18. echo "Service file not found. Skipping service removal."
  19. fi
  20. # Step 2: Delete the virtual environment
  21. if [ -d "$PROJECT_DIR/venv" ]; then
  22. echo "Removing the virtual environment..."
  23. rm -rf "$PROJECT_DIR/venv"
  24. else
  25. echo "Virtual environment not found. Skipping removal."
  26. fi
  27. echo "Uninstallation complete."