Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-27T23:28:58.081Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

uninstall.sh

122 lines · 3.9 KB · shellscript
1#!/usr/bin/env sh
2set -eu
3
4# Uninstalls Omega. OMEGA-DELTA-0036.
5#
6# This script knows no paths of its own. Every path it removes is handed to it
7# by the caller in OMEGA_UNINSTALL_PATHS, one absolute path per line, and that
8# list is derived on the Rust side from the same `paths::` functions the running
9# application uses to write those directories in the first place. See
10# `crates/cli/src/uninstall.rs`.
11#
12# It is written this way because of what it used to be. Up to 0.2.0-rc14 this
13# file was upstream's uninstaller, unchanged: it deleted the upstream editor's
14# application bundle, application-support tree, logs, preferences and remote
15# server directory, announced that the upstream editor had been uninstalled, and
16# removed no Omega path at all. A command advertised as "Uninstall Omega" kept
17# Omega and destroyed the user's other editor. A hard-coded path table is how
18# that happened, and a second hard-coded path table is not the fix, so there is
19# no path table here.
20#
21# Contract:
22#
23#   OMEGA_UNINSTALL_PRODUCT     display name, e.g. "Omega RC"          required
24#   OMEGA_UNINSTALL_PATHS       newline-separated absolute paths       required
25#   OMEGA_UNINSTALL_CONFIG_DIR  removed only if the user says so       optional
26#   OMEGA_UNINSTALL_DRY_RUN     when "1", print the plan, remove nothing
27#   OMEGA_UNINSTALL_ASSUME_YES  when "1", remove the config directory unasked
28#
29# Refusing is the safe direction: an unset or empty contract exits non-zero
30# rather than falling back to a default, because every default this file has
31# ever had belonged to somebody else's product.
32
33refuse() {
34    echo "omega --uninstall: $1" >&2
35    exit 1
36}
37
38product="${OMEGA_UNINSTALL_PRODUCT:-}"
39paths="${OMEGA_UNINSTALL_PATHS:-}"
40config_dir="${OMEGA_UNINSTALL_CONFIG_DIR:-}"
41dry_run="${OMEGA_UNINSTALL_DRY_RUN:-}"
42assume_yes="${OMEGA_UNINSTALL_ASSUME_YES:-}"
43
44[ -n "$product" ] || refuse "OMEGA_UNINSTALL_PRODUCT is not set; refusing to guess what to remove"
45[ -n "$paths" ] || refuse "OMEGA_UNINSTALL_PATHS is empty; refusing to guess what to remove"
46
47check_path() {
48    case "$1" in
49        /*) ;;
50        *) refuse "refusing to remove the relative path '$1'" ;;
51    esac
52    case "$1" in
53        /|/Applications|/Users|/System|/Library|/usr|/bin|/etc|/var|/tmp|"$HOME")
54            refuse "refusing to remove '$1'"
55            ;;
56    esac
57}
58
59# Everything is checked before anything is removed. A here-document keeps the
60# loop in this shell, so a refusal here really does stop the run.
61while IFS= read -r path; do
62    [ -n "$path" ] || continue
63    check_path "$path"
64done <<PLAN
65$paths
66PLAN
67
68if [ -n "$config_dir" ]; then
69    check_path "$config_dir"
70fi
71
72if [ "$dry_run" = "1" ]; then
73    echo "plan: $product"
74    while IFS= read -r path; do
75        [ -n "$path" ] || continue
76        echo "remove: $path"
77    done <<PLAN
78$paths
79PLAN
80    if [ -n "$config_dir" ]; then
81        echo "prompt: $config_dir"
82    fi
83    echo "$product uninstall plan printed; nothing was removed"
84    exit 0
85fi
86
87while IFS= read -r path; do
88    [ -n "$path" ] || continue
89    if [ -e "$path" ] || [ -L "$path" ]; then
90        rm -rf "$path"
91        echo "removed $path"
92    else
93        echo "absent $path"
94    fi
95done <<PLAN
96$paths
97PLAN
98
99if [ -n "$config_dir" ] && { [ -e "$config_dir" ] || [ -L "$config_dir" ]; }; then
100    if [ "$assume_yes" = "1" ]; then
101        rm -rf "$config_dir"
102        echo "removed $config_dir"
103    elif [ -t 0 ]; then
104        printf 'Do you want to keep your %s settings and keymap (%s)? [Y/n] ' "$product" "$config_dir"
105        response=""
106        read -r response || response=""
107        case "$response" in
108            [nN]|[nN][oO])
109                rm -rf "$config_dir"
110                echo "removed $config_dir"
111                ;;
112            *)
113                echo "kept $config_dir"
114                ;;
115        esac
116    else
117        echo "kept $config_dir"
118    fi
119fi
120
121echo "$product has been uninstalled"
122
Served at tenant.openagents/omega Member data and write actions are omitted.