#!/bin/bash # Backstor UI Uninstall Script set -e # Colors GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${YELLOW}Starting Backstor UI Uninstallation...${NC}" # Check for root/sudo if [ "$EUID" -ne 0 ]; then echo -e "${RED}Please run as root (use sudo)${NC}" exit 1 fi SERVICE_NAME="backstor" PROJECT_DIR=$(pwd) SERVER_DIR="$PROJECT_DIR/server" # 1. Stop and Disable Service echo "Stopping and disabling systemd service..." if systemctl list-units --full -all | grep -Fq "$SERVICE_NAME.service"; then systemctl stop $SERVICE_NAME systemctl disable $SERVICE_NAME echo -e "${GREEN}Service stopped and disabled.${NC}" # Remove service file if [ -f "/etc/systemd/system/$SERVICE_NAME.service" ]; then rm "/etc/systemd/system/$SERVICE_NAME.service" echo -e "${GREEN}Service file removed.${NC}" systemctl daemon-reload fi else echo "Service $SERVICE_NAME not found or already removed." fi # 2. Cleanup (Optional) echo -e "\n${YELLOW}Cleanup Options:${NC}" # Remove .env? read -p "Remove configuration file ($SERVER_DIR/.env)? (y/N): " REMOVE_ENV if [[ "$REMOVE_ENV" =~ ^[Yy]$ ]]; then if [ -f "$SERVER_DIR/.env" ]; then rm "$SERVER_DIR/.env" echo -e "${GREEN}Configuration file removed.${NC}" else echo ".env not found." fi fi # Remove node_modules? read -p "Remove dependencies (node_modules)? (y/N): " REMOVE_DEPS if [[ "$REMOVE_DEPS" =~ ^[Yy]$ ]]; then if [ -d "$SERVER_DIR/node_modules" ]; then rm -rf "$SERVER_DIR/node_modules" echo -e "${GREEN}Dependencies removed.${NC}" else echo "node_modules not found." fi fi echo -e "\n${GREEN}Uninstallation Complete!${NC}" echo "Note: The project source code was NOT removed. To delete it, run: rm -rf $PROJECT_DIR"