-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·79 lines (66 loc) · 1.92 KB
/
install.sh
File metadata and controls
executable file
·79 lines (66 loc) · 1.92 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
#!/bin/sh
# Install remotecli — Remote.com partner API CLI.
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/remoteoss/remote-cli/main/install.sh | sh
#
# Env overrides:
# INSTALL_DIR default: /usr/local/bin
# VERSION default: latest (e.g. v1.2.0 to pin)
# REPO default: remoteoss/remote-cli (rarely needed)
set -eu
REPO="${REPO:-remoteoss/remote-cli}"
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
VERSION="${VERSION:-latest}"
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$OS" in
darwin|linux) ;;
*)
printf 'unsupported OS: %s\n' "$OS" >&2
exit 1
;;
esac
ARCH_RAW=$(uname -m)
case "$ARCH_RAW" in
arm64|aarch64) ARCH=arm64 ;;
x86_64|amd64) ARCH=amd64 ;;
*)
printf 'unsupported architecture: %s\n' "$ARCH_RAW" >&2
exit 1
;;
esac
# Published binaries today: darwin/arm64 and linux/amd64. Other combos error early.
case "$OS-$ARCH" in
darwin-arm64|linux-amd64) ;;
*)
printf 'no published binary for %s-%s\n' "$OS" "$ARCH" >&2
printf 'published: darwin-arm64, linux-amd64\n' >&2
exit 1
;;
esac
ASSET="remotecli-${OS}-${ARCH}"
if [ "$VERSION" = "latest" ]; then
URL="https://github.com/${REPO}/releases/latest/download/${ASSET}"
else
URL="https://github.com/${REPO}/releases/download/${VERSION}/${ASSET}"
fi
TMP=$(mktemp)
trap 'rm -f "$TMP"' EXIT INT TERM
printf 'Downloading %s\n' "$URL"
if ! curl -fsSL -o "$TMP" "$URL"; then
printf 'download failed: %s\n' "$URL" >&2
exit 1
fi
chmod +x "$TMP"
DEST="$INSTALL_DIR/remotecli"
mkdir -p "$INSTALL_DIR" 2>/dev/null || true
if [ -w "$INSTALL_DIR" ]; then
mv "$TMP" "$DEST"
else
printf 'Installing to %s requires elevated permissions.\n' "$INSTALL_DIR"
sudo mv "$TMP" "$DEST"
fi
# mv consumed the tempfile; clear the trap so EXIT doesn't try to remove a missing path.
trap - EXIT INT TERM
printf 'Installed: %s\n' "$DEST"
"$DEST" --version