Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions scripts/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
# supported CPU architectures and operating systems
SUPPORTED_ARCH=("x86_64" "arm64")
SUPPORTED_OS=("linux" "darwin")
DOWNLOAD_BASE_URL="cdn.parseable.com/"
DOWNLOAD_BASE_URL="https://github.com/parseablehq/parseable/releases/download"
ARM_APPLE_PREFIX="Parseable_OSS_aarch64-apple-darwin"
INTEL_APPLE_PREFIX="Parseable_OSS_x86_64-apple-darwin"
ARM_LINUX_PREFIX="Parseable_OSS_aarch64-unknown-linux-gnu"
INTEL_LINUX_PREFIX="Parseable_OSS_x86_64-unknown-linux-gnu"
PARSEABLE_PREFIX=${ARM_APPLE_PREFIX}

# Get the system's CPU architecture and operating system
CPU_ARCH=$(uname -m)
Expand Down Expand Up @@ -35,9 +40,26 @@ fi
release=$(curl -s "https://api.github.com/repos/parseablehq/parseable/releases/latest")
# find the release tag
release_tag=$(echo "$release" | grep -o "\"tag_name\":\s*\"[^\"]*\"" | cut -d '"' -f 4)
printf "Found latest release version: $release_tag\n"
if [[ -z "$release_tag" ]]; then
echo "Error: Could not determine the latest release version."
exit 1
fi

printf "Latest Parseable version: $release_tag\n"

download_url=${DOWNLOAD_BASE_URL}${CPU_ARCH}-${OS}.${release_tag}
# Determine the appropriate binary prefix based on OS and CPU architecture
declare -A PREFIX_MAP=(
["darwin_arm64"]=$ARM_APPLE_PREFIX
["darwin_x86_64"]=$INTEL_APPLE_PREFIX
["linux_arm64"]=$ARM_LINUX_PREFIX
["linux_x86_64"]=$INTEL_LINUX_PREFIX
)
key="${OS}_${CPU_ARCH}"
PARSEABLE_PREFIX=${PREFIX_MAP[$key]:-""} || {
echo "Error: unsupported platform $OS/$CPU_ARCH"; exit 1;
}

download_url=${DOWNLOAD_BASE_URL}/${release_tag}/${PARSEABLE_PREFIX}

if [[ -d ${INSTALL_DIR} ]]; then
printf "A Previous version of parseable already exists. Run 'parseable --version' to check the version."
Expand All @@ -48,11 +70,13 @@ else
fi

# Download the binary using curl or wget
printf "Downloading Parseable version $release_tag, for OS: $OS, CPU architecture: $CPU_ARCH\n\n"
printf "Downloading Parseable version $release_tag, for OS: $OS, CPU architecture: $CPU_ARCH\n"
printf "Download URL: $download_url\n\n"

if command -v curl &>/dev/null; then
curl -L -o "${BIN_NAME}" "$download_url"
curl -fL -o "${BIN_NAME}" "$download_url" || { echo "Error: download failed"; exit 1; }
elif command -v wget &>/dev/null; then
wget -O "${BIN_NAME}" "$download_url"
wget -q -O "${BIN_NAME}" "$download_url" || { echo "Error: download failed"; exit 1; }
else
echo "Error: Neither curl nor wget found. Please install either curl or wget."
exit 1
Expand All @@ -62,8 +86,6 @@ printf "Parseable Server was successfully installed at: ${BIN_NAME}\n"

chmod +x "${BIN_NAME}"

printf "Adding parseable to the path\n"
PATH_STR="export PATH=${BIN_DIR}"':$PATH'
echo ${PATH_STR} >> ${RC_FILE_PATH}

echo "parseable was added to the path. Please refresh the environment by sourcing the ${RC_FILE_PATH}"
source ${RC_FILE_PATH}
Loading