#!/bin/sh # Hosted bootstrap for https://install.shakerscan.com # Usage: curl -fsSL https://install.shakerscan.com | sh set -eu INSTALL_URL="https://install.shakerscan.com" REPO_RAW_BASE="${SHAKERSCAN_RAW_BASE:-https://raw.githubusercontent.com/andriyze/shakerscan/main}" INSTALL_DIR="${SHAKERSCAN_HOME:-$HOME/.shakerscan}" BIN_DIR="${SHAKERSCAN_BIN_DIR:-$HOME/.local/bin}" START_AFTER_INSTALL="${SHAKERSCAN_START:-1}" say() { printf '%s\n' "$*" } fail() { say "Error: $*" >&2 exit 1 } have() { command -v "$1" >/dev/null 2>&1 } run_sudo() { if [ "$(id -u)" -eq 0 ]; then "$@" elif have sudo; then sudo "$@" else return 1 fi } detect_package_manager() { if have apt-get; then echo apt elif have dnf; then echo dnf elif have yum; then echo yum elif have pacman; then echo pacman elif have zypper; then echo zypper elif have apk; then echo apk else echo "" fi } install_bootstrap_deps() { missing="" for dep in bash curl; do if ! have "$dep"; then missing="$missing $dep" fi done if [ -z "$missing" ]; then return 0 fi manager="$(detect_package_manager)" [ -n "$manager" ] || fail "missing required tools:$missing. Install bash and curl, then re-run $INSTALL_URL" say "Installing bootstrap tools:$missing" case "$manager" in apt) run_sudo apt-get update run_sudo apt-get install -y bash curl ca-certificates ;; dnf|yum) run_sudo "$manager" -y install bash curl ca-certificates ;; pacman) run_sudo pacman -Sy --needed --noconfirm bash curl ca-certificates ;; zypper) run_sudo zypper --non-interactive install bash curl ca-certificates ;; apk) run_sudo apk add bash curl ca-certificates ;; *) fail "unsupported package manager for bootstrap tools: $manager" ;; esac } download() { src="$1" dst="$2" tmp="${dst}.tmp" if ! curl -fsSL "$src" -o "$tmp"; then rm -f "$tmp" fail "failed to download $src" fi mv "$tmp" "$dst" } install_command() { mkdir -p "$BIN_DIR" launcher="$BIN_DIR/shakerscan" cat > "$launcher" <