Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·69 lines (59 loc) · 2.04 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·69 lines (59 loc) · 2.04 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
#!/bin/sh
# Install the runtimez CLI.
#
# curl -fsSL https://raw.githubusercontent.com/runtimez-com/runtimez-cli/main/install.sh | sh
#
# Verifies the checksum before installing. Set RTZ_VERSION to pin a release, and INSTALL_DIR
# to choose where the binary lands.
set -eu
REPO="runtimez-com/runtimez-cli"
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
os=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m)
case "$arch" in
x86_64|amd64) arch="amd64" ;;
arm64|aarch64) arch="arm64" ;;
*) echo "unsupported architecture: $arch" >&2; exit 1 ;;
esac
case "$os" in
linux|darwin) ;;
*) echo "unsupported OS: $os — on Windows use: scoop install rtz" >&2; exit 1 ;;
esac
version="${RTZ_VERSION:-}"
if [ -z "$version" ]; then
version=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" \
| sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' | head -1)
fi
if [ -z "$version" ]; then
echo "could not determine the latest release; set RTZ_VERSION to pin one" >&2
exit 1
fi
plain="${version#v}"
archive="rtz_${plain}_${os}_${arch}.tar.gz"
base="https://github.com/$REPO/releases/download/$version"
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
echo "Downloading rtz $version ($os/$arch)…"
curl -fsSL "$base/$archive" -o "$tmp/$archive"
curl -fsSL "$base/checksums.txt" -o "$tmp/checksums.txt"
# An unverified download is how a compromised mirror becomes a compromised laptop. No
# checksum, no install.
echo "Verifying checksum…"
( cd "$tmp" && grep " $archive\$" checksums.txt | {
if command -v sha256sum >/dev/null 2>&1; then sha256sum -c -
elif command -v shasum >/dev/null 2>&1; then shasum -a 256 -c -
else echo "no sha256sum or shasum available to verify the download" >&2; exit 1
fi
} )
tar -xzf "$tmp/$archive" -C "$tmp"
if [ -w "$INSTALL_DIR" ]; then
mv "$tmp/rtz" "$INSTALL_DIR/rtz"
else
echo "Installing to $INSTALL_DIR (needs sudo)…"
sudo mv "$tmp/rtz" "$INSTALL_DIR/rtz"
fi
chmod +x "$INSTALL_DIR/rtz" 2>/dev/null || sudo chmod +x "$INSTALL_DIR/rtz"
echo
"$INSTALL_DIR/rtz" version
echo
echo "Next: rtz login"