Last active
January 9, 2024 09:09
-
-
Save ferranbt/9b2765236b1f4297dd06e9e02d3c3432 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
echo "🆙 Starting Suaveup..." | |
while [[ -n $1 ]]; do | |
case $1 in | |
-v | --version) | |
shift | |
VERSION=$1 | |
echo "Found --version flag with value: $VERSION" | |
;; | |
esac | |
shift | |
done | |
# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c | |
get_latest_release() { | |
curl --silent "https://api.github.com/repos/flashbots/suave-geth/releases/latest" | | |
grep '"tag_name":' | | |
sed -E 's/.*"([^"]+)".*/\1/' | |
} | |
# If version is not set, use the latest tag | |
if [ -z "$VERSION" ]; then | |
VERSION=$(get_latest_release) | |
fi | |
echo "🔎 Looking for version: $VERSION" | |
if [ "$(uname -m)" = "x86_64" ]; then | |
ARCH_STRING="linux_amd64" | |
elif [ "$(uname -m)" = "arm64" -a "$(uname -s)" = "Darwin" ]; then | |
ARCH_STRING="darwin_arm64" | |
elif [ "$(uname -m)" = "x86_64" -a "$(uname -s)" = "Darwin" ]; then | |
ARCH_STRING="darwin_amd64" | |
elif [ "$(uname -m)" = "aarch64" -o "$(uname -m)" = "arm64" ]; then | |
ARCH_STRING="linux_arm64" | |
fi | |
# Download the release | |
if command -v curl >/dev/null 2>&1; then | |
curl -sLO https://github.com/flashbots/suave-geth/releases/download/${VERSION}/suave-geth_${VERSION}_${ARCH_STRING}.zip | |
elif command -v wget >/dev/null 2>&1; then | |
wget -qO- https://github.com/flashbots/suave-geth/releases/download/${VERSION}/suave-geth_${VERSION}_${ARCH_STRING}.zip | |
else | |
echo "🚫 Neither curl nor wget are available. Please install one of these and try again." | |
exit 1 | |
fi | |
# use tar to extract the downloaded file and move it to /usr/local/bin | |
unzip suave-geth_${VERSION}_${ARCH_STRING}.zip | |
chmod +x suave-geth | |
if [ ! -d "/usr/local" ]; then | |
sudo mkdir /usr/local | |
fi | |
if [ ! -d "/usr/local/bin" ]; then | |
sudo mkdir /usr/local/bin | |
fi | |
sudo mv suave-geth /usr/local/bin/suave-geth | |
rm suave-geth_${VERSION}_${ARCH_STRING}.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment