Last active
March 6, 2025 06:27
-
-
Save codefromthecrypt/77865a27ad40dc4fa7ef35396a0ba4dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
if command -v curl > /dev/null 2>&1; then | |
DOWNLOADER="curl -sSfLo" | |
elif command -v wget > /dev/null 2>&1; then | |
DOWNLOADER="wget -qO" | |
else | |
echo "Error: Neither curl nor wget is available." >&2 | |
exit 1 | |
fi | |
test -z "$OTEL_DOTNET_AUTO_HOME" && OTEL_DOTNET_AUTO_HOME="$HOME/.otel-dotnet-auto" | |
test -z "$VERSION" && VERSION="1.0.0-alpha.6" | |
DOWNLOAD_DIR="${DOWNLOAD_DIR:=${TMPDIR:=$(mktemp -d)}}" | |
RELEASES_URL="https://github.com/elastic/elastic-otel-dotnet/releases" | |
ARCHIVE="elastic-dotnet-instrumentation-$OS_TYPE.zip" | |
# In case of Linux, use architecture in the download path | |
if echo "$OS_TYPE" | grep -q "linux"; then | |
ARCHIVE="elastic-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)..." | |
${DOWNLOADER} "$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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment