Repository navigation
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·56 lines (50 loc) · 2.03 KB
/
Copy pathuninstall.sh
File metadata and controls
executable file
·56 lines (50 loc) · 2.03 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
#!/usr/bin/env bash
set -euo pipefail
# ============================================================================
# Podspine uninstaller
#
# curl -fsSL https://raw.githubusercontent.com/schubydoo/podspine/main/uninstall.sh | bash
#
# This removes the `podspine` binary that install.sh installed. It does NOT
# touch your audiobook library or any data directory you passed to
# `--data-dir`. Delete those yourself if you want them gone.
#
# Environment overrides:
# PODSPINE_INSTALL_DIR directory to remove from; default: ~/.local/bin
# ============================================================================
REPO_OWNER="schubydoo" # kept for parity with install.sh; unused here
TOOL_NAME="podspine"
if [ -t 1 ]; then
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
else
RED=''; GREEN=''; YELLOW=''; BLUE=''; NC=''
fi
info() { printf "${BLUE}[INFO]${NC} %s\n" "$*"; }
ok() { printf "${GREEN}[ OK ]${NC} %s\n" "$*"; }
warn() { printf "${YELLOW}[WARN]${NC} %s\n" "$*"; }
have() { command -v "$1" >/dev/null 2>&1; }
dir="${PODSPINE_INSTALL_DIR:-${HOME}/.local/bin}"
dest="${dir}/${TOOL_NAME}"
# If the binary is not at the default install path, try to find it on PATH,
# so that the message can point the user at whatever they actually have
# (e.g. a brew/cargo copy this script must not touch).
if [ ! -e "$dest" ]; then
warn "No ${TOOL_NAME} binary at ${dest}."
if found="$(command -v "$TOOL_NAME" 2>/dev/null)"; then
warn "A ${TOOL_NAME} is on your PATH at ${found} — if that's a package-manager"
warn "install (brew, cargo, scoop, pacman, nix), remove it with that tool instead."
fi
exit 0
fi
info "Removing ${dest}"
if [ -w "$dir" ]; then
rm -f "$dest"
elif have sudo; then
warn "${dir} is not writable — using sudo to remove."
sudo rm -f "$dest"
else
printf "Cannot remove %s (not writable, no sudo). Remove it manually.\n" "$dest" >&2
exit 1
fi
ok "Removed ${dest}"
info "Your audiobook library and any --data-dir contents were left untouched."