-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·101 lines (84 loc) · 2.23 KB
/
uninstall.sh
File metadata and controls
executable file
·101 lines (84 loc) · 2.23 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
#!/usr/bin/env bash
set -euo pipefail
APP_NAME="commandcode-bridge"
INSTALL_DIR="$HOME/.local/share/commandcode-bridge"
BIN_DIR="$HOME/.local/bin"
CONFIG_DIR="$HOME/.config/commandcode-bridge"
ENV_FILE="$CONFIG_DIR/env"
USER_UNIT_DIR="$HOME/.config/systemd/user"
SERVICE_FILE="$USER_UNIT_DIR/commandcode-bridge.service"
REMOVE_CONFIG=0
ASSUME_YES=0
usage() {
cat <<'USAGE'
CommandCode Bridge rootless Linux uninstaller.
Usage:
./uninstall.sh [options]
Options:
--purge-config Also remove ~/.config/commandcode-bridge/env and config dir.
By default credentials and env files are preserved.
--yes Non-interactive; do not prompt
-h, --help Show this help
USAGE
}
log() { printf '[%s] %s\n' "$APP_NAME" "$*"; }
while [ "$#" -gt 0 ]; do
case "$1" in
--purge-config)
REMOVE_CONFIG=1
shift
;;
--yes|-y)
ASSUME_YES=1
shift
;;
--help|-h)
usage
exit 0
;;
*)
printf '[%s] ERROR: unknown option: %s\n' "$APP_NAME" "$1" >&2
exit 1
;;
esac
done
confirm() {
[ "$ASSUME_YES" -eq 0 ] || return 0
[ -t 0 ] || return 0
printf 'Uninstall CommandCode Bridge user service and installed files? [y/N]: '
read -r answer || true
case "${answer:-}" in
y|Y|yes|YES) ;;
*) log "Aborted."; exit 0 ;;
esac
}
confirm
if command -v systemctl >/dev/null 2>&1; then
systemctl --user disable --now commandcode-bridge >/dev/null 2>&1 || true
else
log "systemctl not found; removing files only."
fi
rm -f "$SERVICE_FILE"
if command -v systemctl >/dev/null 2>&1; then
systemctl --user daemon-reload >/dev/null 2>&1 || true
systemctl --user reset-failed commandcode-bridge >/dev/null 2>&1 || true
fi
rm -f "$BIN_DIR/commandcode-bridge" "$BIN_DIR/commandcode-router"
rm -rf "$INSTALL_DIR"
if [ "$REMOVE_CONFIG" -eq 1 ]; then
rm -rf "$CONFIG_DIR"
log "Removed config directory: $CONFIG_DIR"
else
log "Preserved config and credentials: $ENV_FILE"
log "Run './uninstall.sh --purge-config' to remove them too."
fi
cat <<EOF
Uninstalled CommandCode Bridge service and installed files.
Removed:
$SERVICE_FILE
$BIN_DIR/commandcode-bridge
$BIN_DIR/commandcode-router
$INSTALL_DIR
Config preserved by default:
$ENV_FILE
EOF