Created
December 21, 2023 18:55
-
-
Save roymoran/60ef845ea271f3ceaca683791528cc60 to your computer and use it in GitHub Desktop.
builder installer script for shell
This file contains 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 | |
# AWS S3 bucket details | |
S3_BUCKET="programbins" | |
S3_PATH="builder/bins" | |
# Base URL for downloading binaries from S3 bucket | |
BASE_URL="https://$S3_BUCKET.s3.amazonaws.com/$S3_PATH" | |
# Detect OS and Architecture | |
OS=$(uname -s) | |
ARCH=$(uname -m) | |
# Map OS and Architecture to your binary naming convention | |
case "$OS" in | |
Darwin) | |
OS="darwin" | |
;; | |
Linux) | |
OS="linux" | |
;; | |
CYGWIN*|MINGW32*|MSYS*|MINGW*) | |
OS="windows" | |
;; | |
esac | |
case "$ARCH" in | |
aarch64|arm64) | |
ARCH="arm64" | |
;; | |
amd64|x86_64) | |
ARCH="amd64" | |
;; | |
arm*) | |
ARCH="arm" | |
;; | |
esac | |
# Construct the download URL | |
BINARY_URL="$BASE_URL/builder_${OS}_${ARCH}.tar.bz2" | |
# Define the local binary path | |
LOCAL_BINARY_PATH="/usr/local/bin/builder" | |
# Download the binary and check if the download was successful | |
curl -L "$BINARY_URL" -o "builder.tar.bz2" | |
if [ $? -ne 0 ]; then | |
exit 1 | |
fi | |
# Extract the binary and check if the extraction was successful | |
tar -xjf "builder.tar.bz2" | |
if [ $? -ne 0 ]; then | |
rm "builder.tar.bz2" | |
exit 1 | |
fi | |
rm "builder.tar.bz2" | |
# Make the binary executable | |
chmod +x builder | |
# Move the binary to the desired location using sudo for necessary permissions | |
sudo mv builder "$LOCAL_BINARY_PATH" | |
echo "Installation complete. 'builder' command is now available." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment