Skip to content

Commit

Permalink
feat: allows installing any custom version for linux (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoliveira authored Jun 30, 2023
1 parent 3ad76b3 commit 8979e9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 8 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand All @@ -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."
Expand All @@ -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
Expand All @@ -69,4 +67,4 @@ while getopts "h?d:" opt; do
esac
done

main
main

0 comments on commit 8979e9b

Please sign in to comment.