Files
icon-color-tool/install.sh
T

58 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
REPO_URL="https://git.rootiest.dev/rootiest/icon-color-tool.git"
DOWNLOAD_URL="https://git.rootiest.dev/rootiest/icon-color-tool/releases/latest/download/icon-color-tool"
INSTALL_DIR="${XDG_BIN_HOME:-$HOME/.local/bin}"
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
BUILD=0
for arg in "$@"; do
if [ "$arg" = "--build" ]; then
BUILD=1
fi
done
echo "Installing icon-color-tool..."
if [ "$BUILD" -eq 1 ]; then
echo "Mode: Building from source"
if ! command -v cargo &> /dev/null; then
echo "Error: 'cargo' (Rust) is required to build from source."
exit 1
fi
if ! command -v git &> /dev/null; then
echo "Error: 'git' is required to clone the repository."
exit 1
fi
git clone --depth 1 "$REPO_URL" "$TMP_DIR/repo"
cd "$TMP_DIR/repo"
echo "Building release binary..."
cargo build --release
cp target/release/icon-color-tool "$TMP_DIR/icon-color-tool"
cd - > /dev/null
else
echo "Mode: Downloading pre-built binary"
if ! curl -sfL "$DOWNLOAD_URL" -o "$TMP_DIR/icon-color-tool"; then
echo "Error: Failed to download binary from $DOWNLOAD_URL"
echo "If the release doesn't exist yet, you can use the --build flag to build from source."
exit 1
fi
fi
mkdir -p "$INSTALL_DIR"
cp "$TMP_DIR/icon-color-tool" "$INSTALL_DIR/icon-color-tool"
chmod +x "$INSTALL_DIR/icon-color-tool"
echo "Successfully installed to $INSTALL_DIR/icon-color-tool"
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo ""
echo "WARNING: $INSTALL_DIR is not in your PATH."
echo "To run 'icon-color-tool' globally, add this directory to your PATH."
echo "For example, add the following line to your ~/.bashrc or ~/.zshrc:"
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
fi