Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more fixes to the download script #776

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ You can download and run the Parseable binary on your laptop.
- Linux or MacOS

```bash
curl https://raw.githubusercontent.com/parseablehq/parseable/main/scripts/download.sh | bash
curl https://logg.ing/install | bash
```

- Windows

```pwsh
powershell -c "irm https://raw.githubusercontent.com/parseablehq/parseable/main/scripts/download.ps1 | iex"
powershell -c "irm https://logg.ing/install-windows | iex"
```

Once this runs successfully, you'll see dashboard at [http://localhost:8000 ↗︎](http://localhost:8000). You can login to the dashboard default credentials `admin`, `admin`.
Expand Down
39 changes: 13 additions & 26 deletions scripts/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
# supported CPU architectures and operating systems
SUPPORTED_ARCH=("x86_64" "arm64")
SUPPORTED_OS=("linux" "darwin")
# Associate binaries with CPU architectures and operating systems
declare -A BINARIES=(
["x86_64-linux"]="Parseable_x86_64-unknown-linux-gnu"
["arm64-linux"]="Parseable_aarch64-unknown-linux-gnu"
["x86_64-darwin"]="Parseable_x86_64-apple-darwin"
["arm64-darwin"]="Parseable_aarch64-apple-darwin"
)
DOWNLOAD_BASE_URL="parseable.gateway.scarf.sh/"

# Get the system's CPU architecture and operating system
CPU_ARCH=$(uname -m)
OS=$(uname -s | tr '[:upper:]' '[:lower:]')

printf "\n=========================\n"
printf "Detected CPU architecture: %s\n" "$CPU_ARCH"
printf "Detected operating system: %s\n" "$OS"

Expand All @@ -34,38 +30,29 @@ if ! echo "${SUPPORTED_OS[@]}" | grep -q "\\b${OS}\\b"; then
echo "Error: Unsupported operating system (${OS})."
exit 1
fi

# Get the latest release information using GitHub API
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"

printf "Fetching release information for parseable...\n"

# Loop through binaries in the release and find the appropriate one
for arch_os in "${CPU_ARCH}-${OS}"; do
binary_name="${BINARIES[$arch_os]}"
download_url=$(echo "$release" | grep -o "\"browser_download_url\":\s*\"[^\"]*${binary_name}\"" | cut -d '"' -f 4)
if [ -n "$download_url" ]; then
break
fi
done
download_url=${DOWNLOAD_BASE_URL}${CPU_ARCH}-${OS}.${release_tag}

printf "Checking for existing installation...\n"
if [[ -d ${INSTALL_DIR} ]]; then
printf "A Previous version of parseable already exists. Run 'parseable --version' to check the version."
printf "or consider removing that before Installing"
printf "or consider removing that before new installation\n"
exit 1

else
printf "No Previous installation found\n"
printf "Installing parseable...\n"
mkdir -p ${BIN_DIR}
fi


# Download the binary using curl or wget
printf "Downloading Parseable version $release_tag, for OS: $OS, CPU architecture: $CPU_ARCH\n\n"
if command -v curl &>/dev/null; then
curl -L -o "${BIN_NAME}" "$download_url" 2&>> /dev/null
curl -L -o "${BIN_NAME}" "$download_url"
elif command -v wget &>/dev/null; then
wget -O "${BIN_NAME}" "$download_url" 2&>> /dev/null
wget -O "${BIN_NAME}" "$download_url"
else
echo "Error: Neither curl nor wget found. Please install either curl or wget."
exit 1
Expand All @@ -79,4 +66,4 @@ 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_PATH}"
echo "parseable was added to the path. Please refresh the environment by sourcing the ${RC_FILE_PATH}"
Loading