mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
89 lines
5.1 KiB
Bash
89 lines
5.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Project N.O.M.A.D. Uninstall Script
|
|
|
|
###################################################################################################################################################################################################
|
|
|
|
# Script | Project N.O.M.A.D. Uninstall Script
|
|
# Version | 1.0.0
|
|
# Author | Crosstalk Solutions, LLC
|
|
# Website | https://crosstalksolutions.com
|
|
|
|
###################################################################################################################################################################################################
|
|
# #
|
|
# Constants & Variables #
|
|
# #
|
|
###################################################################################################################################################################################################
|
|
|
|
NOMAD_DIR="/opt/project-nomad"
|
|
MANAGEMENT_COMPOSE_FILE="${NOMAD_DIR}/docker-compose-management.yaml"
|
|
|
|
###################################################################################################################################################################################################
|
|
# #
|
|
# Functions #
|
|
# #
|
|
###################################################################################################################################################################################################
|
|
|
|
check_current_directory(){
|
|
if [ "$(pwd)" == "${NOMAD_DIR}" ]; then
|
|
echo "Please run this script from a directory other than ${NOMAD_DIR}."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
ensure_management_compose_file_exists(){
|
|
if [ ! -f "${MANAGEMENT_COMPOSE_FILE}" ]; then
|
|
echo "Unable to find the management Docker Compose file at ${MANAGEMENT_COMPOSE_FILE}. There may be a problem with your Project N.O.M.A.D. installation."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
get_uninstall_confirmation(){
|
|
read -p "This script will remove ALL Project N.O.M.A.D. files and containers. THIS CANNOT BE UNDONE. Are you sure you want to continue? (y/n): " choice
|
|
case "$choice" in
|
|
y|Y )
|
|
echo -e "User chose to continue with the uninstallation."
|
|
;;
|
|
n|N )
|
|
echo -e "User chose not to continue with the uninstallation."
|
|
exit 0
|
|
;;
|
|
* )
|
|
echo "Invalid Response"
|
|
echo "User chose not to continue with the uninstallation."
|
|
exit 0
|
|
;;
|
|
esac
|
|
}
|
|
|
|
ensure_docker_installed() {
|
|
if ! command -v docker &> /dev/null; then
|
|
echo "Unable to find Docker. There may be a problem with your Docker installation."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
uninstall_nomad() {
|
|
echo "Stopping and removing Project N.O.M.A.D. containers..."
|
|
docker compose -f "${MANAGEMENT_COMPOSE_FILE}" down
|
|
|
|
echo "Allowing some time for containers to stop..."
|
|
sleep 15
|
|
echo "Containers should be stopped now."
|
|
|
|
echo "Removing Project N.O.M.A.D. files..."
|
|
rm -rf "${NOMAD_DIR}"
|
|
|
|
echo "Project N.O.M.A.D. has been uninstalled. We hope to see you again soon!"
|
|
}
|
|
|
|
###################################################################################################################################################################################################
|
|
# #
|
|
# Main #
|
|
# #
|
|
###################################################################################################################################################################################################
|
|
check_current_directory
|
|
ensure_management_compose_file_exists
|
|
ensure_docker_installed
|
|
get_uninstall_confirmation
|
|
uninstall_nomad |