From 8979e9b42110a9fb89563e5b1b6d4492d6bc4b47 Mon Sep 17 00:00:00 2001 From: Cristian Oliveira Date: Fri, 30 Jun 2023 12:53:39 +0200 Subject: [PATCH] feat: allows installing any custom version for linux (#143) --- README.md | 6 ++++++ install.sh | 18 ++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f0b991b..12d2329 100644 --- a/README.md +++ b/README.md @@ -54,10 +54,16 @@ brew install ergo ``` ### Linux +To install the latest official version ``` curl -s https://raw.githubusercontent.com/cristianoliveira/ergo/master/install.sh | sh ``` +Or to install a specific version +``` +curl -s https://raw.githubusercontent.com/cristianoliveira/ergo/master/install.sh v0.2.5 | sh +``` + ### Windows From powershell run: diff --git a/install.sh b/install.sh index 78b1ab6..1c4f5d7 100755 --- a/install.sh +++ b/install.sh @@ -4,9 +4,10 @@ VERSION_URL="https://raw.githubusercontent.com/cristianoliveira/ergo/master/.ver DOWNLOAD_URL="https://github.com/cristianoliveira/ergo/releases/download" DEST_FOLDER="/usr/local/bin" PROGNAME=`basename "$0"` +VERSION=${1:-$(wget -q -O - "$VERSION_URL")} -die () { -echo "$PROGNAME: [FATAL] $1" >&2; exit ${2:-1} ; +die () { +echo "$PROGNAME: [FATAL] $1" >&2; exit ${2:-1} ; } getplatform(){ @@ -25,12 +26,12 @@ install(){ echo "Using /tmp to store downloaded file" cd /tmp local platform=$(getplatform) - echo "Downloading version $latest_version from repo" - wget -q "$DOWNLOAD_URL/$latest_version/ergo-$latest_version-$platform.tar.gz" + echo "Downloading version $VERSION from repo" + wget -q "$DOWNLOAD_URL/$VERSION/ergo-$VERSION-$platform.tar.gz" [ $? -ne 0 ] && die "unable to download package" echo "Extracting package" - tar -xf ergo-$latest_version-$platform.tar.gz + tar -xf ergo-$VERSION-$platform.tar.gz [ $? -ne 0 ] && die "unable to extract ergo from package" echo "Copying ergo to $DEST_FOLDER. May require sudo password." @@ -50,12 +51,9 @@ show_help(){ } main(){ - - latest_version=$(wget -q -O - "$VERSION_URL") - [ $? -ne 0 ] && die "unable to retrieve latest version information" + [ -z "$VERSION" ] && die "Unable to get the version information to install" install - } while getopts "h?d:" opt; do @@ -69,4 +67,4 @@ while getopts "h?d:" opt; do esac done -main \ No newline at end of file +main