Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | SOFTWARE & RESEARCH4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : SPIDER8# File : scripts/uninstall.sh9# Module : Scripts10# Repository : https://git.spboucher.ai/spider11# Project Website : Not specified12# Created : 2026-12-0413# Last Modified : 2026-12-0414#15# Author : Simon-Pierre Boucher16# Position : Professor of Finance17# Institution : Université du Québec en Outaouais (UQO)18# Organization : SP Boucher19# Website : https://spboucher.ai20# Git : https://git.spboucher.ai21#22# Preferred Contact: contact@spboucher.ai23# Development : dev@spboucher.ai24# Support : support@spboucher.ai25# Security/Admin : admin@spboucher.ai26#27# Copyright (c) 202628# Simon-Pierre Boucher29# All rights reserved where applicable. This file is governed by the30# applicable project license, copyright notices and relevant law.31# Existing third-party rights and notices remain unaffected.32#33# License : ISC34#35# Do not embed credentials, private keys, access tokens,36# certificates or confidential personal information.37#38# =============================================================================39# END OF SP BOUCHER SOURCE HEADER40# =============================================================================4142# Remove SPIDER processes from this node. Data is kept unless --purge-data is given TWICE on purpose.43# Usage: scripts/uninstall.sh [--purge-data --yes-delete-all-collected-data]44set -euo pipefail45PURGE=0; CONFIRM=046for a in "$@"; do case "$a" in --purge-data) PURGE=1 ;; --yes-delete-all-collected-data) CONFIRM=1 ;; esac; done47export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"48if command -v pm2 >/dev/null; then pm2 delete spider-gateway spider-worker >/dev/null 2>&1 || true; pm2 save >/dev/null 2>&1 || true; fi49if [ "$(uname)" = Darwin ]; then50 for l in ai.spboucher.spider.gateway ai.spboucher.spider.worker; do51 launchctl bootout "gui/$(id -u)/$l" 2>/dev/null || true; rm -f "$HOME/Library/LaunchAgents/$l.plist"; done52else53 systemctl --user disable --now spider-gateway spider-worker 2>/dev/null || true54fi55echo "processes removed"56if [ "$PURGE" = 1 ] && [ "$CONFIRM" = 1 ]; then57 ENV_FILE="${SPIDER_ENV_FILE:-$HOME/.config/spider/env}"; [ -f "$ENV_FILE" ] && { set -a; . "$ENV_FILE"; set +a; }58 DB="${SPIDER_DATABASE_URL##*/}"59 [ -n "${SPIDER_DATA_DIR:-}" ] && [ -d "$SPIDER_DATA_DIR/blobs" ] && rm -rf "$SPIDER_DATA_DIR" && echo "data directory removed"60 [ -n "$DB" ] && dropdb --if-exists "$DB" && echo "database $DB dropped"61 rm -rf "$HOME/.config/spider" && echo "configuration and keys removed"62else63 echo "data, database and keys kept (purge needs: --purge-data --yes-delete-all-collected-data)"64fi65