Files
setup/bin/deinstall.sh
2025-12-03 10:41:03 +01:00

54 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# Check if FAST_PATH is set in .bashrc
source ~/.bashrc
if [ -z "$FAST_PATH" ]; then
echo "FAST_PATH is not set in your environment. Please check your .bashrc file."
exit 1
fi
# check if -y flag is provided
if [[ "$1" == "-y" ]]; then
CONFIRM="y"
fi
# if not, prompt the user for confirmation
if [ -z "$CONFIRM" ]; then
echo "This will deinstall Fast from $FAST_PATH and remove all its files."
# Ask for confirmation before proceeding
read -p "Are you sure you want to deinstall Fast from $FAST_PATH? (y/N): " CONFIRM
fi
if [[ "$CONFIRM" != "y" && "$CONFIRM" != "Y" ]]; then
echo "Deinstallation cancelled."
exit 0
fi
# Remove Fast installation directory
echo "Removing Fast installation directory at $FAST_PATH..."
sudo rm -rf "$FAST_PATH"
# Remove FAST_PATH from .bashrc
sed -i '/export FAST_PATH=/d' ~/.bashrc
sed -i '/export PATH=\$FAST_PATH\/bin:\$PATH/d' ~/.bashrc
# find all docker images with "fast" in their name and remove them
# Ask for confirmation before proceeding, default to yes
echo "Removing Docker images related to Fast..."
read -p "Are you sure you want to remove all Docker images related to Fast? (Y/n): " REMOVE_DOCKER
if [[ "$REMOVE_DOCKER" == "n" || "$REMOVE_DOCKER" == "N" ]]; then
echo "Skipping Docker image removal."
exit 0
else
docker images | grep fast/ | awk '{print $1}' | xargs -r docker rmi -f
docker image prune --force
fi
echo "Fast installation directory removed."