-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·87 lines (74 loc) · 2.29 KB
/
uninstall.sh
File metadata and controls
executable file
·87 lines (74 loc) · 2.29 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
#!/usr/bin/env bash
set -euo pipefail
# OpenFOIA uninstaller
# Usage: curl -fsSL https://raw.githubusercontent.com/JordanCoin/openfoia/main/uninstall.sh | bash
#
# For portable installs: run from the USB directory
info() { printf '\033[0;34m%s\033[0m\n' "$*"; }
ok() { printf '\033[0;32m%s\033[0m\n' "$*"; }
warn() { printf '\033[0;33m%s\033[0m\n' "$*"; }
# Detect portable mode
PORTABLE=false
if [ -f ".openfoia-portable" ]; then
PORTABLE=true
fi
if [ "$PORTABLE" = true ]; then
DATA_DIR="$(pwd)/openfoia-data"
VENV_DIR="$(pwd)/.openfoia-venv"
BIN_DIR="$(pwd)/bin"
else
DATA_DIR="$HOME/.openfoia"
VENV_DIR="${OPENFOIA_VENV_DIR:-$HOME/.openfoia-venv}"
BIN_DIR="${OPENFOIA_INSTALL_DIR:-$HOME/.local/bin}"
fi
main() {
info ""
if [ "$PORTABLE" = true ]; then
info " OpenFOIA Uninstaller (portable — $(pwd))"
else
info " OpenFOIA Uninstaller"
fi
info ""
# Remove Python package (pipx — only for standard installs)
if [ "$PORTABLE" = false ] && command -v pipx &>/dev/null; then
pipx uninstall openfoia 2>/dev/null && ok "Removed openfoia (pipx)" || true
fi
# Remove venv
if [ -d "$VENV_DIR" ]; then
rm -rf "$VENV_DIR"
ok "Removed venv ${VENV_DIR}"
fi
# Remove symlinks and binaries
for f in "${BIN_DIR}/openfoia" "${BIN_DIR}/pdf-extract"; do
if [ -f "$f" ] || [ -L "$f" ]; then
rm -f "$f"
ok "Removed $f"
fi
done
# Remove bin dir if empty (portable only)
if [ "$PORTABLE" = true ] && [ -d "$BIN_DIR" ]; then
rmdir "$BIN_DIR" 2>/dev/null || true
fi
# Remove data
if [ -d "$DATA_DIR" ]; then
echo ""
warn "Data directory found: ${DATA_DIR}"
printf " Delete all OpenFOIA data (database, documents, config)? [y/N] "
read -r answer
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
rm -rf "$DATA_DIR"
ok "Removed ${DATA_DIR}"
else
info "Kept ${DATA_DIR}. Remove manually with: rm -rf ${DATA_DIR}"
fi
fi
# Remove portable marker
if [ "$PORTABLE" = true ] && [ -f ".openfoia-portable" ]; then
rm -f ".openfoia-portable"
ok "Removed portable marker"
fi
echo ""
ok "OpenFOIA removed."
info ""
}
main "$@"