-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall-remote.sh
More file actions
executable file
·95 lines (81 loc) · 2.17 KB
/
uninstall-remote.sh
File metadata and controls
executable file
·95 lines (81 loc) · 2.17 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
#!/usr/bin/env bash
set -o errexit -o nounset -o errtrace
# Configuration
readonly REPO="cyunrei/opencode-bwrap"
readonly BINDIR="${HOME}/.local/bin"
readonly CONFIG_DIR="${HOME}/.config/opencode-bwrap"
# Logging Subsystem
declare -g LOG_LEVEL="INFO"
declare -g -A LOG_PRIORITY=(
["DEBUG"]=10
["INFO"]=20
["WARNING"]=30
["ERROR"]=40
["CRITICAL"]=50
)
log_color() {
local color="${1}"
shift
if [[ -t 2 ]]; then
printf "\x1b[0;%sm%s\x1b[0m\n" "${color}" "${*}" >&2
else
printf "%s\n" "${*}" >&2
fi
}
log_message() {
local color="${1}"
local level="${2}"
shift 2
if [[ "${LOG_PRIORITY[${level}]}" -lt "${LOG_PRIORITY[${LOG_LEVEL}]}" ]]; then
return 0
fi
log_color "${color}" "${*}"
}
log_error() { log_message 31 "ERROR" "${@}"; }
log_info() { log_message 32 "INFO" "${@}"; }
log_warning() { log_message 33 "WARNING" "${@}"; }
log_debug() { log_message 34 "DEBUG" "${@}"; }
log_success() { log_message 32 "INFO" "✓ ${*}"; }
# Main function
main() {
echo "=========================================="
echo "Opencode-Bwrap Remote Uninstaller"
echo "Repository: ${REPO}"
echo "=========================================="
echo ""
local script_removed=false
local config_removed=false
if [[ -f "${BINDIR}/opencode-bwrap" ]]; then
log_info "Removing: ${BINDIR}/opencode-bwrap"
rm -f "${BINDIR}/opencode-bwrap"
log_success "Script removed"
script_removed=true
else
log_warning "Script not found at ${BINDIR}/opencode-bwrap"
fi
echo ""
if [[ -d "${CONFIG_DIR}" ]]; then
log_warning "Configuration directory found: ${CONFIG_DIR}"
local reply
read -p "Do you want to remove configuration files? (y/N): " -n 1 -r reply
echo ""
if [[ ${reply} =~ ^[Yy]$ ]]; then
rm -rf "${CONFIG_DIR}"
log_success "Configuration removed"
config_removed=true
else
log_warning "Configuration kept at: ${CONFIG_DIR}"
fi
else
log_info "Configuration directory not found"
fi
echo ""
echo "=========================================="
if [[ "${script_removed}" == true ]] || [[ "${config_removed}" == true ]]; then
log_success "Uninstallation complete!"
else
log_warning "Nothing was removed"
fi
echo "=========================================="
}
main "${@}"