-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·75 lines (67 loc) · 1.92 KB
/
Copy pathuninstall.sh
File metadata and controls
executable file
·75 lines (67 loc) · 1.92 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
#!/usr/bin/env bash
set -euo pipefail
force=0
if [[ "${1:-}" == "--force" ]]; then
force=1
elif [[ $# -ne 0 ]]; then
printf '%s\n' 'usage: uninstall.sh [--force]' >&2
exit 64
fi
codex_home="${CODEX_HOME:-$HOME/.codex}"
state_file="$codex_home/sol-orchestration-state.json"
[[ -r "$state_file" ]] || {
printf 'error: install state not found: %s\n' "$state_file" >&2
exit 66
}
backup_dir="$(python3 - "$state_file" <<'PY'
import json
import sys
print(json.load(open(sys.argv[1]))["backup_dir"])
PY
)"
if [[ $force -ne 1 ]]; then
python3 - "$state_file" "$codex_home" <<'PY'
import hashlib
import json
from pathlib import Path
import sys
state = json.load(open(sys.argv[1]))
home = Path(sys.argv[2])
changed = []
for relative, expected in state["installed_sha256"].items():
path = home / relative
actual = hashlib.sha256(path.read_bytes()).hexdigest() if path.is_file() else None
if actual != expected:
changed.append(relative)
if changed:
print("Refusing to uninstall because managed files changed after installation:", file=sys.stderr)
for relative in changed:
print(f" - {relative}", file=sys.stderr)
print("Review the changes or rerun with --force to restore the pre-install backup.", file=sys.stderr)
raise SystemExit(73)
PY
fi
managed=(
instruction.sol.md
agent-instructions/router.md
agent-instructions/worker.md
agent-instructions/arbiter.md
router.config.toml
worker.config.toml
arbiter.config.toml
bin/codex-tier-exec
bin/codex-sol-uninstall
config.toml
)
for rel in "${managed[@]}"; do
target="$codex_home/$rel"
if grep -Fqx "$rel" "$backup_dir/existed.txt"; then
mkdir -p "$(dirname "$target")"
cp -p "$backup_dir/original/$rel" "$target"
else
rm -f "$target"
fi
done
rm -f "$state_file"
rmdir "$codex_home/agent-instructions" "$codex_home/bin" 2>/dev/null || true
printf '%s\n' "Uninstalled Codex Sol orchestration. Backup retained at $backup_dir"