-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·70 lines (57 loc) · 1.71 KB
/
Copy pathuninstall.sh
File metadata and controls
executable file
·70 lines (57 loc) · 1.71 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
#!/usr/bin/env bash
set -Eeuo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/common.sh"
source "$SCRIPT_DIR/lib/network.sh"
PURGE=0
ASSUME_YES=0
while (($#)); do
case "$1" in
--purge) PURGE=1 ;;
--yes) ASSUME_YES=1 ;;
-h|--help)
printf 'Usage: sudo ./uninstall.sh [--purge] [--yes]\n'
exit 0
;;
*) die "Unknown option: $1" ;;
esac
shift
done
require_root
[[ -r "$STATE_FILE" ]] && load_state
cat <<EOF2
The following runtime files will be removed if present:
$UNIT_PATH
$ACTIVE_LINK
$STATE_FILE
Installed release binaries and source files will also be removed.
EOF2
if (( PURGE )); then
cat <<EOF2
PURGE also permanently deletes:
system user/group: $SERVICE_USER
all Bridge account data and encrypted message cache: $SERVICE_HOME
EOF2
fi
if (( ! ASSUME_YES )); then
confirm_exact "REMOVE" "The service and installed Bridge binaries will be removed."
fi
systemctl disable --now "$SERVICE_NAME" >/dev/null 2>&1 || true
rm -f "$UNIT_PATH"
systemctl daemon-reload
[[ -r "$STATE_FILE" ]] && remove_firewall_rules
rm -f "$ACTIVE_LINK"
rm -rf /opt/proton-bridge "$SOURCE_DIR"
rm -f "$STATE_FILE"
if (( PURGE )); then
confirm_exact "PURGE-DATA" \
"This permanently deletes the Bridge vault, GPG key, credentials, and local message cache."
confirm_exact "DELETE-PROTON-BRIDGE-DATA" \
"Final confirmation: the service account and all of its data will be deleted."
userdel -r "$SERVICE_USER" >/dev/null 2>&1 || true
getent group "$SERVICE_GROUP" >/dev/null 2>&1 && groupdel "$SERVICE_GROUP" || true
rm -rf "$SERVICE_HOME"
else
warn "Bridge account data was preserved at $SERVICE_HOME."
fi
log "Uninstallation complete."