#!/bin/bash # MOXYTOOL Uninstaller Script # Completely removes MOXYTOOL from the system # Check if running as root if [ "$EUID" -ne 0 ]; then echo "Please run as root (sudo ./uninstall.sh)" exit 1 fi # This script can be called directly or through the CLI # When called through the CLI, environment variables are set # REMOVE_CONFIG=yes|no - whether to remove configuration files # REMOVE_DATA=yes|no - whether to remove data files # If not set through CLI, use defaults REMOVE_CONFIG=${REMOVE_CONFIG:-"no"} REMOVE_DATA=${REMOVE_DATA:-"no"} echo "MOXYTOOL Uninstaller" echo "====================" echo "This will completely remove MOXYTOOL from your system." # Find the directory where this script is located SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" # Step 1: Remove global symlinks if [ -L "/usr/local/bin/moxytool" ]; then echo "Removing global symlink from /usr/local/bin/moxytool..." rm -f /usr/local/bin/moxytool fi if [ -L "/usr/bin/moxytool" ]; then echo "Removing global symlink from /usr/bin/moxytool..." rm -f /usr/bin/moxytool fi # Step 2: Remove configuration if requested if [ "$REMOVE_CONFIG" = "yes" ]; then if [ -d "/etc/moxytool" ]; then echo "Removing configuration directory /etc/moxytool..." rm -rf /etc/moxytool fi else if [ -d "/etc/moxytool" ]; then echo "Configuration preserved in /etc/moxytool (use --remove-config to remove)" fi fi # Step 3: Remove data if requested if [ "$REMOVE_DATA" = "yes" ]; then if [ -d "/var/lib/moxytool" ]; then echo "Removing data directory /var/lib/moxytool..." rm -rf /var/lib/moxytool fi if [ -d "/var/log/moxytool" ]; then echo "Removing log directory /var/log/moxytool..." rm -rf /var/log/moxytool fi if [ -d "/tmp/moxytool-vgpu-setup" ]; then echo "Removing temporary installation directory /tmp/moxytool-vgpu-setup..." rm -rf /tmp/moxytool-vgpu-setup fi else if [ -d "/var/lib/moxytool" ] || [ -d "/var/log/moxytool" ]; then echo "Data and logs preserved (use --remove-data to remove)" fi fi # Step 4: Remove installation directory if [ -d "/opt/moxytool" ]; then echo "Removing installation directory /opt/moxytool..." rm -rf /opt/moxytool fi echo "" echo "================================================" echo " MOXYTOOL Uninstallation Complete" echo "================================================" echo "" echo "MOXYTOOL has been removed from your system." if [ "$REMOVE_CONFIG" = "no" ] && [ -d "/etc/moxytool" ]; then echo "" echo "Configuration has been preserved in /etc/moxytool" echo "To remove it, run: sudo rm -rf /etc/moxytool" fi if [ "$REMOVE_DATA" = "no" ]; then if [ -d "/var/lib/moxytool" ] || [ -d "/var/log/moxytool" ]; then echo "" echo "Data and logs have been preserved in:" [ -d "/var/lib/moxytool" ] && echo " - /var/lib/moxytool" [ -d "/var/log/moxytool" ] && echo " - /var/log/moxytool" [ -d "/tmp/moxytool-vgpu-setup" ] && echo " - /tmp/moxytool-vgpu-setup" echo "To remove them, run:" [ -d "/var/lib/moxytool" ] && echo " sudo rm -rf /var/lib/moxytool" [ -d "/var/log/moxytool" ] && echo " sudo rm -rf /var/log/moxytool" [ -d "/tmp/moxytool-vgpu-setup" ] && echo " sudo rm -rf /tmp/moxytool-vgpu-setup" fi fi echo "" echo "Thank you for using MOXYTOOL!" echo ""