-
Notifications
You must be signed in to change notification settings - Fork 43
/
install.sh
executable file
·60 lines (51 loc) · 2.05 KB
/
install.sh
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
#!/bin/sh
set -e
# Determine the latest version of the Tailscale UDM package
VERSION="${1:-latest}"
if [ "${VERSION}" = "latest" ]; then
# shellcheck disable=SC2034 # Disable incorrect unused variable warning
PACKAGE_URL="https://github.com/SierraSoftworks/tailscale-udm/releases/latest/download/tailscale-udm.tgz"
else
PACKAGE_URL="https://github.com/SierraSoftworks/tailscale-udm/releases/download/${VERSION}/tailscale-udm.tgz"
fi
# Setup a temporary directory to download the package
WORKDIR="$(mktemp -d || exit 1)"
trap 'rm -rf ${WORKDIR}' EXIT
# Download the Tailscale-UDM package
curl -sSLf --ipv4 -o "${WORKDIR}/tailscale.tgz" "$PACKAGE_URL"
if [ -x "$(which ubnt-device-info)" ]; then
OS_VERSION="${FW_VERSION:-$(ubnt-device-info firmware_detail | grep -oE '^[0-9]+')}"
elif [ -f "/usr/lib/version" ]; then
# UCKP == Unifi CloudKey Gen2 Plus
# example /usr/lib/version file contents:
# UCKP.apq8053.v2.5.11.b2ebfc7.220801.1419
# UCKP.apq8053.v3.0.17.8102bbc.230210.1526
# UCKG2 == UniFi CloudKey Gen2
# example /usr/lib/version file contents:
# UCKG2.apq8053.v3.1.13.3584673.230626.2239
if [ "$(grep -c '^UCKP.*\.v[0-9]\.' /usr/lib/version)" = '1' ]; then
OS_VERSION="$(sed -e 's/UCKP.*.v\(.\)\..*/\1/' /usr/lib/version)"
elif [ "$(grep -c '^UCKG2.*\.v[0-9]\.' /usr/lib/version)" = '1' ]; then
OS_VERSION="$(sed -e 's/UCKG2.*.v\(.\)\..*/\1/' /usr/lib/version)"
else
echo "Could not detect OS Version. /usr/lib/version contains:"
cat /usr/lib/version
exit 1
fi
else
echo "Could not detect OS Version. No ubnt-device-info, no version file."
exit 1
fi
if [ "$OS_VERSION" = '1' ]; then
export PACKAGE_ROOT="/mnt/data/tailscale"
else
export PACKAGE_ROOT="/data/tailscale"
fi
# Extract the package
tar xzf "${WORKDIR}/tailscale.tgz" -C "$(dirname -- "${PACKAGE_ROOT}")"
# Run the setup script to ensure that Tailscale is installed
# shellcheck source=package/manage.sh
"$PACKAGE_ROOT/manage.sh" install "${TAILSCALE_VERSION}"
# Start the tailscaled daemon
# shellcheck source=package/manage.sh
"$PACKAGE_ROOT/manage.sh" start