Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | SOFTWARE & RESEARCH4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : SPIDER8# File : scripts/rollback.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# Roll the code of this node back to a previous release tag or commit, then restart its processes.43# The database is NOT rolled back: migrations are additive; restoring data is scripts/restore.sh.44# Usage: scripts/rollback.sh <tag-or-commit>45set -euo pipefail46cd "$(dirname "$0")/.."47REF="${1:?usage: rollback.sh <tag-or-commit>}"48git diff --quiet && git diff --cached --quiet || { echo "working tree has uncommitted changes; commit or stash first" >&2; exit 1; }49PREV="$(git rev-parse --short HEAD)"50git fetch --tags -q origin51git checkout -q "$REF"52export PATH="/opt/homebrew/bin:/usr/local/bin:$HOME/.local/bin:$PATH"53uv pip install -q -e ".[browser]"54if command -v pm2 >/dev/null; then pm2 restart spider-gateway spider-worker --update-env >/dev/null 2>&1 || true; fi55echo "rolled back from $PREV to $(git rev-parse --short HEAD) ($REF); return with: scripts/rollback.sh $PREV"56