Repository navigation
Expand file tree
/
Copy pathuninstall.sh
More file actions
138 lines (124 loc) · 4.33 KB
/
Copy pathuninstall.sh
File metadata and controls
138 lines (124 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/sh
set -e
# ============================================================
# Adaptive Learner Uninstaller
#
# Removes the Adaptive Learner installation, Docker resources, and
# launcher manifest in a single command.
#
# Usage:
# cd ~/adaptive_learner && bash uninstall.sh
# ============================================================
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
INSTALL_DIR="$(cd "$(dirname "$0")" && pwd)"
COMPOSE_FILE="docker-compose.prod.yml"
echo ""
echo -e "${RED}========================================${NC}"
echo -e "${RED} Adaptive Learner Uninstaller${NC}"
echo -e "${RED}========================================${NC}"
echo ""
echo -e "${YELLOW}WARNING: This will permanently remove:${NC}"
echo ""
echo " 1. The Adaptive Learner Docker stack (containers)"
echo " 2. All Adaptive Learner Docker volumes (books, chapters, database)"
echo " 3. All Adaptive Learner Docker images"
echo " 4. The launcher configuration manifest"
echo " 5. The installation directory: ${INSTALL_DIR}"
echo ""
echo -e "${RED}Your books and chapters will be deleted.${NC}"
echo -e "${RED}Export your work BEFORE proceeding.${NC}"
echo ""
printf "Type 'yes' to confirm uninstall: "
read -r CONFIRM
if [ "$CONFIRM" != "yes" ]; then
echo ""
echo "Uninstall cancelled."
exit 0
fi
echo ""
# --- Step 1: Stop Docker stack ---
echo -e "${YELLOW}Stopping Adaptive Learner Docker stack...${NC}"
if [ -f "$INSTALL_DIR/$COMPOSE_FILE" ]; then
docker compose -f "$INSTALL_DIR/$COMPOSE_FILE" down 2>/dev/null || true
echo -e "${GREEN} Stack stopped.${NC}"
else
echo " No compose file found, skipping."
fi
# --- Step 2: Remove Docker volumes ---
echo -e "${YELLOW}Removing Adaptive Learner Docker volumes...${NC}"
VOLUMES=$(docker volume ls --filter name=adaptive_learner -q 2>/dev/null || true)
if [ -n "$VOLUMES" ]; then
echo "$VOLUMES" | xargs docker volume rm 2>/dev/null || true
echo -e "${GREEN} Volumes removed.${NC}"
else
echo " No Adaptive Learner volumes found."
fi
# --- Step 3: Remove Docker images ---
echo -e "${YELLOW}Removing Adaptive Learner Docker images...${NC}"
IMAGES=$(docker images --filter reference='*adaptive_learner*' -q 2>/dev/null || true)
if [ -n "$IMAGES" ]; then
echo "$IMAGES" | xargs docker image rm --force 2>/dev/null || true
echo -e "${GREEN} Images removed.${NC}"
else
echo " No Adaptive Learner images found."
fi
# --- Step 4: Remove launcher manifest ---
echo -e "${YELLOW}Removing launcher manifest...${NC}"
MANIFEST_REMOVED="no"
# Detect platform and set manifest directory
OS_TYPE="$(uname -s 2>/dev/null || echo "unknown")"
case "$OS_TYPE" in
MINGW*|MSYS*|CYGWIN*|Windows*)
# Windows (Git Bash / MSYS2 / Cygwin)
MANIFEST_DIR="${APPDATA}/adaptive_learner"
;;
Darwin*)
# macOS
MANIFEST_DIR="${HOME}/Library/Application Support/adaptive_learner"
;;
*)
# Linux and other Unix
MANIFEST_DIR="${HOME}/.config/adaptive_learner"
;;
esac
if [ -d "$MANIFEST_DIR" ]; then
rm -rf "$MANIFEST_DIR"
MANIFEST_REMOVED="yes"
echo -e "${GREEN} Manifest removed: ${MANIFEST_DIR}${NC}"
else
echo " No manifest directory found at: ${MANIFEST_DIR}"
fi
# Also remove legacy launcher.json if it exists under APPDATA/Adaptive Learner
# (capital B, used by the old launcher config path)
case "$OS_TYPE" in
MINGW*|MSYS*|CYGWIN*|Windows*)
LEGACY_DIR="${APPDATA}/Adaptive Learner"
if [ -d "$LEGACY_DIR" ]; then
rm -rf "$LEGACY_DIR"
echo -e "${GREEN} Legacy config removed: ${LEGACY_DIR}${NC}"
fi
;;
esac
# --- Step 5: Remove install directory (last, since script lives here) ---
echo -e "${YELLOW}Removing installation directory...${NC}"
echo " ${INSTALL_DIR}"
cd /
rm -rf "$INSTALL_DIR"
echo -e "${GREEN} Directory removed.${NC}"
# --- Summary ---
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} Adaptive Learner has been uninstalled.${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo " Removed:"
echo " - Docker stack, volumes, and images"
echo " - Launcher manifest ($MANIFEST_REMOVED)"
echo " - Installation directory"
echo ""
echo " To reinstall:"
echo " curl -fsSL https://raw.githubusercontent.com/astrapi69/adaptive_learner/main/install.sh | bash"
echo ""