/ uninstall.sh
uninstall.sh
1 #!/bin/bash 2 # InterBrain Uninstall Script 3 # For macOS/Linux systems 4 # 5 # Usage: 6 # bash uninstall.sh # Normal mode (preserves shared dependencies) 7 # bash uninstall.sh --full # Nuclear mode (removes everything, including vault) 8 9 # Parse command-line arguments 10 FULL_UNINSTALL=false 11 while [[ $# -gt 0 ]]; do 12 case $1 in 13 --full) 14 FULL_UNINSTALL=true 15 shift 16 ;; 17 *) 18 shift 19 ;; 20 esac 21 done 22 23 echo "đī¸ InterBrain Uninstall Script" 24 echo "==================================" 25 echo "" 26 27 # Color output 28 GREEN='\033[0;32m' 29 YELLOW='\033[1;33m' 30 RED='\033[0;31m' 31 BLUE='\033[0;34m' 32 NC='\033[0m' # No Color 33 34 # Function to check if command exists 35 command_exists() { 36 command -v "$1" >/dev/null 2>&1 37 } 38 39 # Function to print success 40 success() { 41 echo -e "${GREEN}â $1${NC}" 42 } 43 44 # Function to print warning 45 warning() { 46 echo -e "${YELLOW}â ī¸ $1${NC}" 47 } 48 49 # Function to print error 50 error() { 51 echo -e "${RED}â $1${NC}" 52 } 53 54 # Function to print info 55 info() { 56 echo -e "${BLUE}âšī¸ $1${NC}" 57 } 58 59 if [ "$FULL_UNINSTALL" = true ]; then 60 echo "" 61 echo "ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ" 62 error "â ī¸ NUCLEAR MODE: FULL UNINSTALL â ī¸" 63 echo "ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ" 64 echo "" 65 warning "This will remove EVERYTHING:" 66 echo " âĸ All InterBrain dependencies (gh, rad, ollama, python venv)" 67 echo " âĸ Homebrew" 68 echo " âĸ Git" 69 echo " âĸ Node.js" 70 echo " âĸ Obsidian" 71 echo " âĸ Your entire vault and all DreamNodes (DATA LOSS!)" 72 echo "" 73 error "This is intended ONLY for testing fresh installations!" 74 echo "" 75 else 76 echo "This will uninstall InterBrain dependencies:" 77 echo " âĸ GitHub CLI (gh)" 78 echo " âĸ Radicle (rad)" 79 echo " âĸ Ollama" 80 echo " âĸ Python dependencies (whisper_streaming virtual environment)" 81 echo "" 82 warning "This will NOT uninstall:" 83 echo " âĸ Homebrew (shared with other apps)" 84 echo " âĸ Git (shared with other apps)" 85 echo " âĸ Node.js (shared with other apps)" 86 echo " âĸ Obsidian (shared with other apps)" 87 echo " âĸ Your vault or DreamNodes (data is preserved)" 88 echo "" 89 info "For complete removal (testing only), use: bash uninstall.sh --full" 90 echo "" 91 fi 92 93 if [ -t 0 ]; then 94 read -p "Continue with uninstall? [y/N]: " -n 1 -r 95 echo "" 96 if [[ ! $REPLY =~ ^[Yy]$ ]]; then 97 echo "" 98 info "Uninstall cancelled." 99 exit 0 100 fi 101 fi 102 103 echo "" 104 echo "ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ" 105 echo "Starting uninstall process..." 106 echo "ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ" 107 echo "" 108 109 # Uninstall GitHub CLI 110 echo "1. Uninstalling GitHub CLI..." 111 if command_exists gh; then 112 if [[ "$OSTYPE" == "darwin"* ]]; then 113 brew uninstall gh 2>/dev/null && success "GitHub CLI uninstalled" || warning "GitHub CLI uninstall failed (may not be installed via Homebrew)" 114 else 115 sudo apt remove gh -y 2>/dev/null && success "GitHub CLI uninstalled" || warning "GitHub CLI uninstall failed" 116 fi 117 else 118 info "GitHub CLI not installed, skipping" 119 fi 120 121 # Uninstall Radicle 122 echo "" 123 echo "2. Uninstalling Radicle..." 124 if command_exists rad; then 125 # Stop Radicle node if running 126 if rad node status 2>/dev/null | grep -qi "running"; then 127 info "Stopping Radicle node..." 128 rad node stop 2>/dev/null || true 129 fi 130 131 # Remove Radicle installation 132 if [ -d "$HOME/.radicle" ]; then 133 rm -rf "$HOME/.radicle" 134 success "Radicle uninstalled" 135 else 136 warning "Radicle directory not found" 137 fi 138 else 139 info "Radicle not installed, skipping" 140 fi 141 142 # Uninstall Ollama 143 echo "" 144 echo "3. Uninstalling Ollama..." 145 if command_exists ollama; then 146 if [[ "$OSTYPE" == "darwin"* ]]; then 147 # Stop Ollama service if running via Homebrew 148 if brew list ollama &>/dev/null; then 149 brew services stop ollama 2>/dev/null || true 150 brew uninstall ollama 2>/dev/null && success "Ollama uninstalled" || warning "Ollama uninstall failed" 151 else 152 warning "Ollama installed but not via Homebrew - manual removal required" 153 info "Remove Ollama manually: rm -rf ~/.ollama" 154 fi 155 else 156 # Linux - remove Ollama directory 157 if [ -d "$HOME/.ollama" ]; then 158 rm -rf "$HOME/.ollama" 159 success "Ollama uninstalled" 160 fi 161 fi 162 else 163 info "Ollama not installed, skipping" 164 fi 165 166 # Remove Python virtual environment for transcription 167 echo "" 168 echo "4. Removing Python transcription environment..." 169 DEFAULT_VAULT_NAME="DreamVault" # Only the vault name, not a hardcoded username path 170 DEFAULT_VAULT_PARENT="$HOME" # Will resolve to current user's home directory 171 172 # Try to find InterBrain installation 173 POSSIBLE_PATHS=( 174 "$DEFAULT_VAULT_PARENT/$DEFAULT_VAULT_NAME/InterBrain" 175 "$HOME/DreamVault/InterBrain" 176 "$(pwd)" 177 ) 178 179 TRANSCRIPTION_DIR="" 180 for path in "${POSSIBLE_PATHS[@]}"; do 181 if [ -d "$path/src/features/realtime-transcription/scripts/venv" ]; then 182 TRANSCRIPTION_DIR="$path/src/features/realtime-transcription/scripts" 183 break 184 fi 185 done 186 187 if [ -n "$TRANSCRIPTION_DIR" ]; then 188 rm -rf "$TRANSCRIPTION_DIR/venv" 189 success "Python transcription environment removed" 190 else 191 info "Python transcription environment not found, skipping" 192 fi 193 194 # NUCLEAR MODE: Remove shared dependencies and vault 195 if [ "$FULL_UNINSTALL" = true ]; then 196 echo "" 197 echo "5. Uninstalling Obsidian..." 198 if [[ "$OSTYPE" == "darwin"* ]]; then 199 if [ -d "/Applications/Obsidian.app" ]; then 200 # Kill Obsidian if running 201 killall Obsidian 2>/dev/null || true 202 sleep 1 203 rm -rf "/Applications/Obsidian.app" 204 success "Obsidian uninstalled" 205 else 206 info "Obsidian not found, skipping" 207 fi 208 209 # Remove Obsidian config 210 if [ -d "$HOME/Library/Application Support/obsidian" ]; then 211 rm -rf "$HOME/Library/Application Support/obsidian" 212 success "Obsidian config removed" 213 fi 214 else 215 warning "Non-macOS system - manually remove Obsidian if needed" 216 fi 217 218 echo "" 219 echo "6. Uninstalling Node.js..." 220 if command_exists node; then 221 if [[ "$OSTYPE" == "darwin"* ]]; then 222 brew uninstall node 2>/dev/null && success "Node.js uninstalled" || warning "Node.js uninstall failed" 223 else 224 sudo apt remove nodejs -y 2>/dev/null && success "Node.js uninstalled" || warning "Node.js uninstall failed" 225 fi 226 else 227 info "Node.js not installed, skipping" 228 fi 229 230 echo "" 231 echo "7. Uninstalling Git..." 232 if command_exists git; then 233 if [[ "$OSTYPE" == "darwin"* ]]; then 234 brew uninstall git 2>/dev/null && success "Git uninstalled" || warning "Git uninstall failed" 235 else 236 sudo apt remove git -y 2>/dev/null && success "Git uninstalled" || warning "Git uninstall failed" 237 fi 238 else 239 info "Git not installed, skipping" 240 fi 241 242 echo "" 243 echo "8. Uninstalling Homebrew..." 244 if [[ "$OSTYPE" == "darwin"* ]] && command_exists brew; then 245 warning "Removing Homebrew (this may take a few minutes)..." 246 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" -- --force 247 success "Homebrew uninstalled" 248 else 249 info "Homebrew not installed or not on macOS, skipping" 250 fi 251 252 echo "" 253 echo "9. Removing vault and all DreamNodes..." 254 VAULT_PATH="$DEFAULT_VAULT_PARENT/$DEFAULT_VAULT_NAME" 255 if [ -d "$VAULT_PATH" ]; then 256 rm -rf "$VAULT_PATH" 257 success "Vault removed: $VAULT_PATH" 258 else 259 info "Vault not found at default location, skipping" 260 fi 261 fi 262 263 echo "" 264 echo "ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ" 265 echo "Uninstall complete!" 266 echo "ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ" 267 echo "" 268 269 if [ "$FULL_UNINSTALL" = true ]; then 270 success "Complete system cleanup finished" 271 echo "" 272 warning "All InterBrain components and data have been removed" 273 echo "" 274 info "To reinstall from scratch, run:" 275 info " bash <(curl -fsSL https://raw.githubusercontent.com/ProjectLiminality/InterBrain/main/install.sh)" 276 else 277 success "InterBrain dependencies removed" 278 echo "" 279 info "Your vault and DreamNodes are preserved at:" 280 info " $DEFAULT_VAULT_PARENT/$DEFAULT_VAULT_NAME" 281 echo "" 282 info "To reinstall InterBrain, run:" 283 info " bash <(curl -fsSL https://raw.githubusercontent.com/ProjectLiminality/InterBrain/main/install.sh)" 284 fi 285 286 echo ""