interplane.Get Omega
Read in your language

omega-mcp

aien-dev/omega-mcp

Brought by drakestapleton

branch main Branches Tags History

omega-mcp / tools / releases.sh

37 lines · 1793 bytes Raw Blame History
1#!/bin/sh
2# Retire alarm: list the releases under PREFIX and the legacy PREFIX/omega-mcp with the live processes that run
3# from each. A release with no live process that is not current is RETIRABLE; this script never deletes anything.
4#
5# tools/releases.sh PREFIX [CONFIG[=PENDING] ...]
6#
7# Each CONFIG is an MCP client configuration; every line of it that still names the legacy PREFIX/omega-mcp
8# is printed as "legacy path still configured in CONFIG:LINE", with "(replacement pending: PENDING)" when a
9# prepared replacement file is given. Exit 0; the last line counts the retirable entries.
10set -eu
11[ $# -ge 1 ] || { echo "usage: tools/releases.sh PREFIX [CONFIG[=PENDING] ...]" >&2; exit 2; }
12prefix=$(cd "$1" && pwd -P)
13shift
14cur=$(readlink "$prefix/current" 2>/dev/null || true)
15live() { for d in /proc/[0-9]*; do [ "$(readlink "$d/exe" 2>/dev/null)" = "$1" ] && printf ' %s' "${d#/proc/}"; done; true; }
16n=0
17row() {
18 pids=$(live "$2/omega-mcp")
19 tag=""; [ "$3" = cur ] && tag=" current"
20 if [ -n "$pids" ]; then state="IN USE pids:$pids"
21 elif [ -n "$tag" ]; then state="IDLE"
22 else state="RETIRABLE"; n=$((n+1)); fi
23 echo "$1 $2 omega-mcp $(sha256sum "$2/omega-mcp" | cut -c1-16) omc $(sha256sum "$2/omc" | cut -c1-16)$tag $state"
24}
25if [ -f "$prefix/omega-mcp" ] && [ ! -L "$prefix/omega-mcp" ]; then row legacy "$prefix" no; fi
26for r in "$prefix"/releases/*/; do
27 [ -d "$r" ] || continue
28 r=${r%/}; c=no; [ "releases/${r##*/}" = "$cur" ] && c=cur
29 row release "$r" $c
30done
31for c in "$@"; do
32 f=${c%%=*}; pend=""; [ "$f" != "$c" ] && pend=" (replacement pending: ${c#*=})"
33 grep -nF "$prefix/omega-mcp" "$f" 2>/dev/null | grep -vF "$prefix/omega-mcp/" | while IFS=: read -r ln _; do
34 echo "legacy path still configured in $f:$ln$pend"
35 done
36done
37echo "retirable $n"