Bash script to update Livepeer

As a new orchestrator, I updated livepeer for the first time today to 0.5.21
I wrote a shell script I can run every time there’s a new update which does some basic error checking.
It should work even on Windows, tho I have only tested on Linux.

Posting it here in case it helps others:

# Update Livepeer binary from Github
# Expects bash, jq, curl, grep, sed and tar to be installed, usually available even on embedded systems
# Windows Subsystem for Linux (WSL) or Cygwin should provide every utility on Windows
set -e

# Requires you to specify _ostype and the path to the existing install in _lptdir below
# Do not append the directory created by the tar.gz like livepeer-linux-amd64 or livepeer-windows-amd64

### User config starts

_ostype=linux # Either 1) darwin 2) windows 3) linux

### User config ends


_curver=$($_curdir/livepeer -version \
	| sed -n 's/^Livepeer Node Version: \([^-]*\).*$/\1/p')

_newver=$(curl -sL \
	| jq -r '.assets[].browser_download_url' \
	| grep -F -e $_ostype)

url="$_newver" ver=${url%/*} ver=${ver##*/v}; declare url ver

echo "Current Version: $_curver => New Version: $ver"

if [ "$ver" != "$_curver" ]; then
	echo "Installing $_newver"
	pushd $_lptdir > /dev/null
	curl -sLo livepeer-$_ostype-amd64.tar.gz "$_newver"
	tarball="$(find . -name "livepeer-$_ostype-amd64.tar.gz" 2>/dev/null)"
	tar -xzf "$tarball"
	chmod +x livepeer-$_ostype-amd64/livepeer
	popd > /dev/null
	echo ".. Upgrade complete!"


	echo "Latest version already installed"


The latest version can be found at Upgrade Livepeer Go binaries · GitHub