Skip to content

Commit

Permalink
(fix) install.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Mar 29, 2024
1 parent af393eb commit 91d71af
Showing 1 changed file with 16 additions and 35 deletions.
51 changes: 16 additions & 35 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
#!/bin/sh

GOBREW_BIN_DIR=$HOME/.gobrew/bin
BIN_DIR=$(pwd)

# check if env GOBREW_ROOT is set
if [ -n "$GOBREW_ROOT" ]; then
GOBREW_BIN_DIR=$GOBREW_ROOT/.gobrew/bin
fi

mkdir -p $GOBREW_BIN_DIR

GOBREW_ARCH_BIN=''
GOBREW_BIN='gobrew'
GOBREW_VERSION=${1:-latest}
THE_ARCH_BIN=''
THIS_PROJECT_NAME='email_extractor'

THISOS=$(uname -s)
ARCH=$(uname -m)
Expand All @@ -20,57 +12,46 @@ case $THISOS in
Linux*)
case $ARCH in
arm64)
GOBREW_ARCH_BIN="gobrew-linux-arm64"
THE_ARCH_BIN="$THIS_PROJECT_NAME-linux-arm64"
;;
aarch64)
GOBREW_ARCH_BIN="gobrew-linux-arm64"
THE_ARCH_BIN="$THIS_PROJECT_NAME-linux-arm64"
;;
armv6l)
GOBREW_ARCH_BIN="gobrew-linux-arm"
THE_ARCH_BIN="$THIS_PROJECT_NAME-linux-arm"
;;
armv7l)
GOBREW_ARCH_BIN="gobrew-linux-arm"
THE_ARCH_BIN="$THIS_PROJECT_NAME-linux-arm"
;;
*)
GOBREW_ARCH_BIN="gobrew-linux-amd64"
THE_ARCH_BIN="$THIS_PROJECT_NAME-linux-amd64"
;;
esac
;;
Darwin*)
case $ARCH in
arm64)
GOBREW_ARCH_BIN="gobrew-darwin-arm64"
THE_ARCH_BIN="$THIS_PROJECT_NAME-darwin-arm64"
;;
*)
GOBREW_ARCH_BIN="gobrew-darwin-amd64"
THE_ARCH_BIN="$THIS_PROJECT_NAME-darwin-amd64"
;;
esac
;;
Windows|MINGW64_NT*)
GOBREW_ARCH_BIN="gobrew-windows-amd64.exe"
GOBREW_BIN="gobrew.exe"
THE_ARCH_BIN="$THIS_PROJECT_NAME-windows-amd64.exe"
THIS_PROJECT_NAME="$THIS_PROJECT_NAME.exe"
;;
esac

if [ -z "$GOBREW_ARCH_BIN" ]; then
if [ -z "$THE_ARCH_BIN" ]; then
echo "This script is not supported on $THISOS and $ARCH"
exit 1
fi

DOWNLOAD_URL="https://github.com/kevincobain2000/gobrew/releases/download/$GOBREW_VERSION/$GOBREW_ARCH_BIN"
if [ "$GOBREW_VERSION" = "latest" ]; then
DOWNLOAD_URL="https://github.com/kevincobain2000/gobrew/releases/$GOBREW_VERSION/download/$GOBREW_ARCH_BIN"
fi

echo "Installing gobrew from: $DOWNLOAD_URL"
echo ""

curl -L --progress-bar $DOWNLOAD_URL -o $GOBREW_BIN_DIR/$GOBREW_BIN
curl -kL --progress-bar https://github.com/kevincobain2000/$THIS_PROJECT_NAME/releases/latest/download/$THE_ARCH_BIN -o "$BIN_DIR"/"$THIS_PROJECT_NAME"

chmod +x $GOBREW_BIN_DIR/$GOBREW_BIN
chmod +x "$BIN_DIR"/$THIS_PROJECT_NAME

echo "Installed successfully to: $GOBREW_BIN_DIR/$GOBREW_BIN"
echo "Installed successfully to: $BIN_DIR/$THIS_PROJECT_NAME"

echo "============================"
$GOBREW_BIN_DIR/$GOBREW_BIN help
echo "============================"

0 comments on commit 91d71af

Please sign in to comment.