#!/bin/sh set -e # Donut Browser installation script for Linux # # Usage: # curl -fsSL https://autobrowser.app/install.sh | sh # # Options: # --dry-run Print commands without executing # --setup-repo Only configure the repository, don't install REPO_URL="https://repo.autobrowser.app" PACKAGE_NAME="donut" DRY_RUN=${DRY_RUN:-} REPO_ONLY=${REPO_ONLY:-0} while [ $# -gt 0 ]; do case "$1" in --dry-run) DRY_RUN=1 ;; --setup-repo) REPO_ONLY=1 ;; --*) echo "Unknown option: $1" >&2 echo "Usage: $0 [--dry-run] [--setup-repo]" >&2 exit 1 ;; esac shift $(( $# > 0 ? 1 : 0 )) done command_exists() { command -v "$@" > /dev/null 2>&1 } is_dry_run() { [ -n "$DRY_RUN" ] } get_distribution() { if [ -r /etc/os-release ]; then . /etc/os-release && echo "$ID" fi } do_install() { case "$(uname -s)" in Darwin*) echo "ERROR: This script is for Linux only." echo "For macOS, install via Homebrew: brew install --cask donut" echo "Or download from https://autobrowser.app" exit 1 ;; esac user="$(id -un 2>/dev/null || true)" sh_c='sh -c' if [ "$user" != 'root' ]; then if command_exists sudo; then sh_c='sudo -E sh -c' elif command_exists su; then sh_c='su -c' else echo "ERROR: This installer needs root privileges. Install sudo or run as root." >&2 exit 1 fi fi if is_dry_run; then sh_c="echo" fi lsb_dist="$(get_distribution)" lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')" case "$lsb_dist" in ubuntu|debian|raspbian|linuxmint|pop|elementary|zorin) echo "Detected Debian-based distribution: $lsb_dist" ( if ! is_dry_run; then set -x; fi $sh_c 'apt-get -qq update >/dev/null' $sh_c "apt-get -y -qq install ca-certificates >/dev/null" $sh_c "echo 'deb [trusted=yes] $REPO_URL/deb stable main' > /etc/apt/sources.list.d/donutbrowser.list" $sh_c 'apt-get -qq update >/dev/null' ) if [ "$REPO_ONLY" = "1" ]; then echo "Repository configured. Run 'sudo apt install $PACKAGE_NAME' to install." exit 0 fi ( if ! is_dry_run; then set -x; fi $sh_c "DEBIAN_FRONTEND=noninteractive apt-get -y -qq install $PACKAGE_NAME >/dev/null" ) ;; fedora|centos|rhel|rocky|alma|ol) echo "Detected RPM-based distribution: $lsb_dist" ( if ! is_dry_run; then set -x; fi $sh_c "tee /etc/yum.repos.d/donutbrowser.repo > /dev/null <&2 echo "" >&2 echo "Supported distributions:" >&2 echo " Debian/Ubuntu: apt-based (Debian, Ubuntu, Linux Mint, Pop!_OS, etc.)" >&2 echo " RPM-based: dnf/yum (Fedora, RHEL, CentOS, Rocky, Alma)" >&2 echo " openSUSE/SLES: zypper-based" >&2 echo "" >&2 echo "You can also download packages directly from:" >&2 echo " https://github.com/auto-browser/donutbrowser/releases/latest" >&2 exit 1 ;; esac echo "" echo "Donut Browser has been installed successfully!" echo "Run 'donut' to launch, or find it in your application menu." } # Wrap in function for protection against partial download via curl | sh do_install