#!/bin/bash # Base URL for the repository BASE_URL="https://github.com/polaco1782/linux-static-binaries/raw/refs/heads/master" # Check if ~/.local/bin is in the PATH environment variable if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then echo "Error: ~/.local/bin is not in your PATH. Please add it by running:" echo "export PATH=\$HOME/.local/bin:\$PATH" exit 1 fi # Detect system architecture ARCH=$(uname -m) case $ARCH in x86_64|i686) ARCH_FOLDER="x86-i686" ;; armv8*|aarch64) ARCH_FOLDER="armv8-aarch64" ;; armv7l*) ARCH_FOLDER="armv7l-eabihf" ;; *) echo "Error: Unsupported architecture: $ARCH" exit 1 ;; esac # Get the argument if [ -z "$1" ]; then echo "Error: No argument provided. Usage: $0 " exit 1 fi COMMAND=$1 # Define the destination directory and file DEST_DIR="$HOME/.local/bin" DEST_FILE="$DEST_DIR/$COMMAND" # Check if wget or curl is available if command -v wget > /dev/null 2>&1; then DOWNLOAD_CMD="wget -O $DEST_FILE" elif command -v curl > /dev/null 2>&1; then DOWNLOAD_CMD="curl -L -o $DEST_FILE" else echo "Error: Neither wget nor curl is installed. Please install one of them." exit 1 fi # Create the destination directory if it doesn't exist mkdir -p "$DEST_DIR" # Download the file URL="$BASE_URL/$ARCH_FOLDER/$COMMAND" echo "Downloading $COMMAND for $ARCH..." # Do overrides on some applications case "$COMMAND" in neofetch) URL="https://github.com/dylanaraps/neofetch/raw/refs/heads/master/neofetch" ;; esac $DOWNLOAD_CMD "$URL" if [ $? -ne 0 ]; then echo "Error: Failed to download $URL" rm $DEST_FILE exit 1 fi # Make the file executable chmod +x "$DEST_FILE" if [ $? -eq 0 ]; then echo "$COMMAND installed successfully to $DEST_FILE" else echo "Error: Failed to set executable permissions on $DEST_FILE" exit 1 fi