#!/bin/sh ### # # This script will download and install the latest release # of boom - the Boomack Client CLI # # https://boomack.com # ### command_name="boom" base_url="https://download.boomack.com/boom/latest" prefix="/usr/local" # detect platform machine="$(uname -m)" os="$(uname -o)" arch="$machine" platform="" if [ "$machine" = "i686" ]; then if [ "$os" = "GNU/Linux" ]; then platform="unknown-linux-gnu" else >&2 echo "Sorry. Your platform is not supported." exit 1 fi elif [ "$machine" = "x86_64" ]; then if [ "$os" = "GNU/Linux" ]; then platform="unknown-linux-gnu" else platform="unknown-linux-musl" fi elif [ "$machine" = "armv6l" ]; then arch="arm" if [ "$os" = "GNU/Linux" ]; then platform="unknown-linux-gnueabihf" else >&2 echo "Sorry. Your platform is not supported." exit 1 fi elif [ "$machine" = "armv7l" ]; then arch="armv7" if [ "$os" = "GNU/Linux" ]; then platform="unknown-linux-gnueabihf" else >&2 echo "Sorry. Your platform is not supported." exit 1 fi elif [ "$machine" = "aarch64" ]; then if [ "$os" = "Android" ]; then platform="aarch64-linux-android" else >&2 echo "Sorry. Your platform is not supported." exit 1 fi # elif [ "$os" = "GNU/Linux" ]; then # platform="aarch64-unknown-linux-gnu" # else # platform="aarch64-unknown-linux-musl" # fi else >&2 echo "Sorry. Your platform is not supported." exit 1 fi name="${command_name}_$arch-$platform" url="$base_url/$name.gz" # echo "Architectur: $arch" # echo "Platform: $platform" # echo "URL: $url" location="$(pwd)" cd $HOME # detect http client and download archive and checksum if command -v curl 2>&1 >/dev/null; then echo "Downloading compressed binary..." curl -o "$name.gz" "$url" if [ $? -ne 0 ]; then >&2 echo "Downloading compressed binary failed." if [ -f "$name.gz" ]; then rm "$name.gz"; fi cd "$location" exit 3 fi echo "Downloading checksum file..." curl -o "$name.gz.sha256" "$url.sha256" if [ $? -ne 0 ]; then >&2 echo "Downloading checksum file failed." if [ -f "$name.gz.sha256" ]; then rm "$name.gz.sha256"; fi cd "$location" exit 3 fi elif command -v wget 2>&1 >/dev/null; then echo "Downloading compressed binary..." wget -q --show-progress -O "$name.gz" "$url" if [ $? -ne 0 ]; then >&2 echo "Downloading compressed binary failed." if [ -f "$name.gz" ]; then rm "$name.gz"; fi cd "$location" exit 3 fi echo "Downloading checksum file..." wget -q --show-progress -O "$name.gz.sha256" "$url.sha256" if [ $? -ne 0 ]; then >&2 echo "Downloading checksum file failed." if [ -f "$name.gz.sha256" ]; then rm "$name.gz.sha256"; fi cd "$location" exit 3 fi else >&2 echo "No HTTP client found. Install wget or cURL and try again." cd "$location" exit 2 fi # check checksum echo "Checking file integrity..." if ! sha256sum -c "$name.gz.sha256"; then >&2 echo "Downloaded files are currupted." if [ -f "$name.gz" ]; then rm "$name.gz"; fi if [ -f "$name.gz.sha256" ]; then rm "$name.gz.sha256"; fi cd "$location" exit 4 fi rm "$name.gz.sha256" # decompress file echo "Inflating file..." if ! gzip -d -f "$name.gz"; then >&2 echo "Inflating file failed." if [ -f "$name.gz" ]; then rm "$name.gz"; fi if [ -f "$name" ]; then rm "$name"; fi cd "$location" exit 5 fi # installing file echo "Installing $command_name command into $prefix/bin..." if ! ( mv "$name" $command_name && sudo install $command_name "$prefix/bin" ); then >&2 echo "Installing the $command_name command into $prefix/bin failed." if [ -f "$name" ]; then rm "$name"; fi if [ -f "./$command_name" ]; then rm "./$command_name"; fi cd "$location" exit 6 fi rm "./$command_name" # show version number echo "Showing version number..." if ! boom --version; then >&2 echo "Boomack Client CLI did not work properly. Removing it." sudo rm "$prefix/bin/$command_name" cd "$location" exit 7 fi # cleanup if [ -f "$name.gz.sha256" ]; then rm "$name.gz.sha256"; fi if [ -f "$name.gz" ]; then rm "$name.gz"; fi if [ -f "$name" ]; then rm "$name"; fi if [ -f "./$command_name" ]; then rm "./$command_name"; fi cd "$location" echo "Finished."