-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·135 lines (124 loc) · 4.79 KB
/
Copy pathuninstall.sh
File metadata and controls
executable file
·135 lines (124 loc) · 4.79 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
# remote-agent-stack uninstaller
#
# Removes the userland artifacts installed by install.sh:
# - /usr/local/bin/copilot-agent symlink
# - /usr/local/bin/ca symlink (short alias)
# - /usr/local/bin/ss and /usr/local/bin/vncfix symlinks (GUI helpers)
# - /etc/resolver/ts.net
# - ~/.tmux.conf managed block (status-bar-off settings)
#
# Does NOT uninstall Homebrew packages (tmux, tailscale) — those may be
# used by other tools on your system. Run `brew uninstall tmux tailscale`
# manually if you want them gone.
#
# Does NOT remove ~/.config/remote-agent-stack/ unless --purge is given.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
WRAPPER_SRC="$REPO_ROOT/bin/copilot-agent"
PURGE=false
for arg in "$@"; do
case "$arg" in
--purge) PURGE=true ;;
*) echo "Unknown arg: $arg" >&2; exit 2 ;;
esac
done
bold() { printf '\033[1m%s\033[0m\n' "$*"; }
ok() { printf ' \033[32m✓\033[0m %s\n' "$*"; }
skip() { printf ' \033[2m·\033[0m %s\n' "$*"; }
todo() { printf ' \033[36m→\033[0m %s\n' "$*"; }
bold "Removing copilot-agent wrapper"
if [ -L /usr/local/bin/copilot-agent ] || [ -e /usr/local/bin/copilot-agent ]; then
todo "sudo rm /usr/local/bin/copilot-agent"
sudo rm -f /usr/local/bin/copilot-agent
ok "removed"
else
skip "/usr/local/bin/copilot-agent not present"
fi
bold "Removing 'ca' short alias"
# Only remove the link if it points at THIS clone's wrapper (exact absolute
# match). Anything else — a foreign tool's symlink, a hand-rolled alias, a
# real file — is left alone.
if [ -L /usr/local/bin/ca ] && [ "$(readlink /usr/local/bin/ca)" = "$WRAPPER_SRC" ]; then
todo "sudo rm /usr/local/bin/ca"
sudo rm -f /usr/local/bin/ca
ok "removed"
elif [ -L /usr/local/bin/ca ]; then
skip "/usr/local/bin/ca symlinks to $(readlink /usr/local/bin/ca) — not ours, leaving alone"
elif [ -e /usr/local/bin/ca ]; then
skip "/usr/local/bin/ca exists and is not our symlink — leaving it alone"
else
skip "/usr/local/bin/ca not present"
fi
bold "Removing GUI helpers (ss, vncfix)"
# Same exact-match guard as the 'ca' alias: only remove links that point at
# THIS clone's bin/ scripts; leave foreign symlinks and real files alone.
for _pair in "ss:$REPO_ROOT/bin/ss" "vncfix:$REPO_ROOT/bin/vncfix"; do
_name="${_pair%%:*}"; _src="${_pair##*:}"; _dst="/usr/local/bin/$_name"
if [ -L "$_dst" ] && [ "$(readlink "$_dst")" = "$_src" ]; then
todo "sudo rm $_dst"
sudo rm -f "$_dst"
ok "removed"
elif [ -L "$_dst" ]; then
skip "$_dst symlinks to $(readlink "$_dst") — not ours, leaving alone"
elif [ -e "$_dst" ]; then
skip "$_dst exists and is not our symlink — leaving it alone"
else
skip "$_dst not present"
fi
done
bold "Removing MagicDNS resolver"
if [ -f /etc/resolver/ts.net ]; then
todo "sudo rm /etc/resolver/ts.net"
sudo rm -f /etc/resolver/ts.net
sudo dscacheutil -flushcache 2>/dev/null || true
ok "removed"
else
skip "/etc/resolver/ts.net not present"
fi
bold "Removing tmux config managed block"
# Strip ONLY our marked block from ~/.tmux.conf; leave any hand-written
# config the user added around it untouched. If the file ends up empty
# (it only ever held our block), remove it entirely.
TMUXCONF_DST="$HOME/.tmux.conf"
TMUX_BLOCK_BEGIN="# >>> remote-agent-stack (managed) >>>"
TMUX_BLOCK_END="# <<< remote-agent-stack (managed) <<<"
if [ -f "$TMUXCONF_DST" ] && grep -qF "$TMUX_BLOCK_BEGIN" "$TMUXCONF_DST"; then
TMUX_TMP="$(mktemp)"
awk -v b="$TMUX_BLOCK_BEGIN" -v e="$TMUX_BLOCK_END" '
$0==b { inblk=1; next }
$0==e { inblk=0; next }
!inblk { print }
' "$TMUXCONF_DST" > "$TMUX_TMP"
# Collapse to empty if nothing but blank lines remain.
if [ -n "$(tr -d '[:space:]' < "$TMUX_TMP")" ]; then
mv "$TMUX_TMP" "$TMUXCONF_DST"
ok "removed managed block from $TMUXCONF_DST (kept your other config)"
else
rm -f "$TMUX_TMP" "$TMUXCONF_DST"
ok "removed $TMUXCONF_DST (it only held our block)"
fi
pgrep -x tmux >/dev/null 2>&1 && tmux set -g status on 2>/dev/null || true
else
skip "no remote-agent-stack block in $TMUXCONF_DST"
fi
if $PURGE; then
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/remote-agent-stack"
bold "Purging config"
if [ -d "$CONFIG_DIR" ]; then
rm -rf "$CONFIG_DIR"
ok "removed $CONFIG_DIR"
else
skip "$CONFIG_DIR not present"
fi
fi
echo
bold "Done."
echo
echo "Not removed (do these manually if you want them gone):"
echo " • Homebrew packages: brew uninstall tmux tailscale"
echo " • Tailscale daemon: sudo brew services stop tailscale"
echo " • FDA grants: System Settings → Privacy & Security → Full Disk Access"
echo " • Copilot CLI + ~/.copilot: per Copilot CLI docs"
echo " • Tailscale network state: sudo tailscale logout"
[ "$PURGE" = "false" ] && echo " • Wrapper config: re-run with --purge"