#!/bin/bash # Halt on any error set -e pathadd() { if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then PATH="${PATH:+"$PATH:"}$1" fi } # Determine the processor architecture case $(uname -m) in x86_64) archValue="x64" ;; i386|i486|i586|i686|i786) archValue="x86" ;; aarch64) archValue="arm64" ;; *) echo "Unsupported architecture" exit 1 ;; esac # Set the URL of the binary URL_OF_THE_BINARY="https://www.fluxzy.io/release/download/cli/linux/latest?arch=$archValue" # Create a temporary directory TEMP_DIR=$(mktemp -d) echo "Downloading release from: $URL_OF_THE_BINARY" # Download the zipped file to the temp folder curl -sL --fail $URL_OF_THE_BINARY -o $TEMP_DIR/fluxzy.zip || echo "Failed to download the release from $URL_OF_THE_BINARY" # Create the target directory (if it doesn't exist) mkdir -p $HOME/.local/fluxzy-cli/bin # Clear the directory if it's not empty if [ "$(ls -A $HOME/.local/fluxzy-cli/bin)" ]; then echo "Cleaning the $HOME/.local/fluxzy-cli/bin directory..." rm -rf $HOME/.local/fluxzy-cli/bin/* fi # Unzip the downloaded file to the target directory unzip -q $TEMP_DIR/fluxzy.zip -d $HOME/.local/fluxzy-cli/bin # Make the binary executable chmod +x $HOME/.local/fluxzy-cli/bin/fluxzy # Cleanup the temp directory rm -rf $TEMP_DIR # Create a symbolink of $HOME/.local/fluxzy-cli/bin/fluxzy to /usr/bin/fluxzy and ask interactively for sudo # if the user is not root echo "" echo "*********************************************************" echo "Fluxzy is installed at $HOME/.local/fluxzy-cli/bin/fluxzy" echo "Do you want to install the command for the current user?" echo "If you don't, Hit Ctrl+C to terminate this setup" sudo ln -s $HOME/.local/fluxzy-cli/bin/fluxzy /usr/bin/fluxzy