-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathotel-dotnet-auto-install.sh.template
74 lines (64 loc) · 1.9 KB
/
otel-dotnet-auto-install.sh.template
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
#!/bin/sh
set -e
# guess OS_TYPE if not provided
if [ -z "$OS_TYPE" ]; then
case "$(uname -s | tr '[:upper:]' '[:lower:]')" in
cygwin_nt*|mingw*|msys_nt*)
OS_TYPE="windows"
;;
linux*)
if [ "$(ldd /bin/ls | grep -m1 'musl')" ]; then
OS_TYPE="linux-musl"
else
OS_TYPE="linux-glibc"
fi
;;
darwin*)
OS_TYPE="macos"
;;
esac
fi
case "$OS_TYPE" in
"linux-glibc"|"linux-musl"|"macos"|"windows")
;;
*)
echo "Set the operating system type using the OS_TYPE environment variable. Supported values: linux-glibc, linux-musl, macos, windows." >&2
exit 1
;;
esac
# guess OS architecture if not provided
if [ -z "$ARCHITECTURE" ]; then
case $(uname -m) in
x86_64) ARCHITECTURE="x64" ;;
aarch64) ARCHITECTURE="arm64" ;;
esac
fi
case "$ARCHITECTURE" in
"x64"|"arm64")
;;
*)
echo "Set the architecture type using the ARCHITECTURE environment variable. Supported values: x64, arm64." >&2
exit 1
;;
esac
test -z "$OTEL_DOTNET_AUTO_HOME" && OTEL_DOTNET_AUTO_HOME="$HOME/.otel-dotnet-auto"
test -z "$VERSION" && VERSION="v{{VERSION}}"
DOWNLOAD_DIR="${DOWNLOAD_DIR:=${TMPDIR:=$(mktemp -d)}}"
RELEASES_URL="https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases"
ARCHIVE="opentelemetry-dotnet-instrumentation-$OS_TYPE.zip"
# In case of Linux, use architecture in the download path
if echo "$OS_TYPE" | grep -q "linux"; then
ARCHIVE="opentelemetry-dotnet-instrumentation-$OS_TYPE-$ARCHITECTURE.zip"
fi
LOCAL_PATH="${LOCAL_PATH:=$DOWNLOAD_DIR/$ARCHIVE}"
if [ ! -f "${LOCAL_PATH}" ]; then
(
cd "$DOWNLOAD_DIR"
echo "Downloading $VERSION for $OS_TYPE ($LOCAL_PATH)..."
curl -sSfLo "$LOCAL_PATH" "$RELEASES_URL/download/$VERSION/$ARCHIVE"
)
else
echo "Using local installation archive: $LOCAL_PATH"
fi
rm -rf "$OTEL_DOTNET_AUTO_HOME"
unzip -q "$LOCAL_PATH" -d "$OTEL_DOTNET_AUTO_HOME"