-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.sh
More file actions
78 lines (64 loc) · 1.67 KB
/
Copy pathuninstall.sh
File metadata and controls
78 lines (64 loc) · 1.67 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
#!/bin/sh
set -eu
# RoamCore uninstaller (HA-only beta).
#
# Thin wrapper that delegates to:
# homeassistant/uninstall.sh
#
# Usage (on a Home Assistant host with /bin/sh):
# curl -fsSL https://raw.githubusercontent.com/roamcore/RoamCore/main/uninstall.sh | sh
#
# Optional env vars:
# ROAMCORE_REF=main|<tag>|<sha>
# ROAMCORE_REPO=https://github.com/roamcore/RoamCore
# CONFIG_DIR=/config
ROAMCORE_REPO="${ROAMCORE_REPO:-https://github.com/roamcore/RoamCore}"
ROAMCORE_REF="${ROAMCORE_REF:-main}"
CONFIG_DIR="${CONFIG_DIR:-/config}"
need() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "ERROR: missing required command: $1" >&2
exit 1
fi
}
need sh
fetch() {
url="$1"
out="$2"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$url" -o "$out"
elif command -v wget >/dev/null 2>&1; then
wget -qO "$out" "$url"
else
echo "ERROR: need curl or wget to download $url" >&2
exit 1
fi
}
repo_slug() {
echo "$ROAMCORE_REPO" \
| sed -e 's#^https\?://github.com/##' -e 's#\.git$##' -e 's#/*$##'
}
SLUG="$(repo_slug)"
RAW_URL="https://raw.githubusercontent.com/${SLUG}/${ROAMCORE_REF}/homeassistant/uninstall.sh"
WORK_BASE="${WORK_BASE:-}"
if [ -z "${WORK_BASE}" ]; then
if [ -d /mnt/data ] && [ -w /mnt/data ]; then
WORK_BASE="/mnt/data/tmp"
else
WORK_BASE="/tmp"
fi
fi
WORK="$WORK_BASE/roamcore-uninstaller.$$"
mkdir -p "$WORK"
SCRIPT="$WORK/uninstall-ha.sh"
cleanup() {
rm -rf "$WORK" 2>/dev/null || true
}
trap cleanup EXIT
echo "== RoamCore uninstaller (wrapper) =="
echo "Delegating to: $RAW_URL"
fetch "$RAW_URL" "$SCRIPT"
ROAMCORE_REPO="$ROAMCORE_REPO" \
ROAMCORE_REF="$ROAMCORE_REF" \
CONFIG_DIR="$CONFIG_DIR" \
sh "$SCRIPT"