From 7b406e764f7a9977908884170c3f1227827eb5e5 Mon Sep 17 00:00:00 2001 From: "othman.suseno" Date: Mon, 8 Dec 2025 15:56:32 +0700 Subject: [PATCH] Add uninstall script --- uninstall.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 uninstall.sh diff --git a/uninstall.sh b/uninstall.sh new file mode 100755 index 0000000..1b7294c --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,68 @@ +#!/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"