-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·98 lines (78 loc) · 2.44 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh
set -eu
if ! command -v curl >/dev/null; then
echo "Error: \`curl\` is required to download the \`appsignal-run\` binary"
exit 1
fi
if ! command -v tar >/dev/null; then
echo "Error: \`tar\` is required to extract the \`appsignal-run\` binary"
exit 1
fi
# This value is automatically updated during the release process;
# see `script/write_version`.
LAST_RELEASE="0.2.2"
VERSION="${APPSIGNAL_RUN_VERSION:-"$LAST_RELEASE"}"
INSTALL_FOLDER="${APPSIGNAL_RUN_INSTALL_FOLDER:-"/usr/local/bin"}"
# Expected values are "linux" or "darwin".
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
if [ "$OS" = "linux" ]; then
OS_FRIENDLY="Linux"
VENDOR="unknown"
elif [ "$OS" = "darwin" ]; then
OS_FRIENDLY="macOS"
VENDOR="apple"
else
echo "Error: Unsupported OS: $OS"
exit 1
fi
# Expected values are "x86_64", "aarch64" or "arm64".
ARCH="$(uname -m)"
ARCH_FRIENDLY="$ARCH"
# Rename "arm64" to "aarch64" to match the naming convention used by the Rust
# toolchain target triples.
if [ "$ARCH" = "arm64" ]; then
ARCH="aarch64"
fi
# Rename "aarch64" to "arm64" for the user-friendly architecture name.
if [ "$ARCH" = "aarch64" ]; then
ARCH_FRIENDLY="arm64"
fi
if [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "aarch64" ]; then
echo "Error: Unsupported architecture: $ARCH"
exit 1
fi
EXTRA=""
EXTRA_FRIENDLY=""
# Only check for musl with ldd on Linux; macOS doesn't have either.
if [ "$OS" = "linux" ]; then
ldd_has_musl() {
ldd --version 2>&1 | grep -q musl
}
if ldd_has_musl; then
EXTRA="musl"
EXTRA_FRIENDLY="musl"
else
# Do not add "gnu" to the friendly triple, as it is the assumed default.
EXTRA="gnu"
fi
fi
if [ -z "$EXTRA" ]; then
TRIPLE="${ARCH}-${VENDOR}-${OS}"
else
TRIPLE="${ARCH}-${VENDOR}-${OS}-${EXTRA}"
fi
if [ -z "$EXTRA_FRIENDLY" ]; then
TRIPLE_FRIENDLY="${OS_FRIENDLY} (${ARCH_FRIENDLY})"
else
TRIPLE_FRIENDLY="${OS_FRIENDLY} (${ARCH_FRIENDLY}, ${EXTRA_FRIENDLY})"
fi
if [ "$VERSION" = "latest" ]; then
URL="https://github.com/appsignal/appsignal-run/releases/latest/download/$TRIPLE.tar.gz"
VERSION_FRIENDLY="latest version"
else
URL="https://github.com/appsignal/appsignal-run/releases/download/v$VERSION/$TRIPLE.tar.gz"
VERSION_FRIENDLY="version $VERSION"
fi
echo "Downloading $VERSION_FRIENDLY of the \`appsignal-run\` binary for $TRIPLE_FRIENDLY..."
curl --progress-bar -SL "$URL" | tar -C "$INSTALL_FOLDER" -xz
echo "Done! Installed \`appsignal-run\` binary at \`$INSTALL_FOLDER/appsignal-run\`."