Files
crib/installer.sh
2026-01-28 18:57:23 +00:00

44 lines
1.2 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -e
BINARY_NAME="crib"
GITHUB_URL="https://github.com/SyedM-dev/crib/releases/download/v0.0.1-alpha/crib-linux-x86_64"
# 1⃣ Check dependencies
missing=()
command -v ruby >/dev/null 2>&1 || missing+=("ruby")
ldconfig -p | grep libmagic >/dev/null 2>&1 || missing+=("libmagic")
if [ ${#missing[@]} -ne 0 ]; then
echo "Missing dependencies: ${missing[*]}"
echo "Install them using your package manager:"
echo "Ubuntu/Debian: sudo apt install ruby libmagic1"
echo "Arch: sudo pacman -S ruby file"
echo "Void: sudo xbps-install -Sy ruby file"
exit 1
fi
# 2⃣ Ask installation path
echo "Install locally (~/.local/bin) or globally (/usr/bin)? [l/g]"
read -r choice
case "$choice" in
l | L) INSTALL_DIR="$HOME/.local/bin" ;;
g | G) INSTALL_DIR="/usr/bin" ;;
*)
echo "Invalid choice"
exit 1
;;
esac
mkdir -p "$INSTALL_DIR"
# 3⃣ Download the binary
echo "Downloading binary..."
curl -L "$GITHUB_URL" -o "$INSTALL_DIR/$BINARY_NAME"
chmod +x "$INSTALL_DIR/$BINARY_NAME"
# 4⃣ Optional: confirm
echo "$BINARY_NAME installed to $INSTALL_DIR"
echo "You can run it with: $BINARY_NAME"
echo "Remember to add $INSTALL_DIR to PATH if not already."