#!/bin/sh # Installs Sajilo on Linux. # # curl -fsSL https://sajilo.fyi/install/linux | sh # # Picks the package your distribution uses: the .deb on Debian, Ubuntu, Mint # and their family; the .rpm on Fedora and openSUSE; the AUR package on Arch # when an AUR helper is installed; and the AppImage everywhere else, with a # menu entry so it opens like any other app. Every file comes from Sajilo's # GitHub releases, through sajilo.fyi's download links. # # Read it before you run it: https://sajilo.fyi/install/linux set -eu SITE="https://sajilo.fyi" APP_DIR="${XDG_DATA_HOME:-$HOME/.local/share}" BIN_DIR="$HOME/.local/bin" say() { printf '\033[1m%s\033[0m\n' "$*"; } fail() { printf '\033[31mError:\033[0m %s\n' "$*" >&2 exit 1 } has() { command -v "$1" >/dev/null 2>&1; } # Wrapped in a function and called on the last line, so a download cut off # halfway through never runs half a script. main() { [ "$(uname -s)" = "Linux" ] || fail "this installer is for Linux. Get Sajilo for your system at $SITE" case "$(uname -m)" in x86_64 | amd64) ;; *) fail "Sajilo runs on 64-bit x86 (x86_64) Linux only, and this is $(uname -m)." ;; esac has curl || fail "curl is needed to download Sajilo." # What the distribution is and what it is like, from os-release. ID="" ID_LIKE="" if [ -r /etc/os-release ]; then # shellcheck disable=SC1091 . /etc/os-release fi family=" ${ID:-} ${ID_LIKE:-} " SUDO="" if [ "$(id -u)" -ne 0 ]; then has sudo && SUDO="sudo" fi case "$family" in *" debian "* | *" ubuntu "*) if has apt-get; then install_deb; return; fi ;; *" fedora "* | *" rhel "* | *" suse "* | *" opensuse "*) if has dnf || has zypper; then install_rpm; return; fi ;; *" arch "*) if { has yay || has paru; } && aur_has_sajilo; then install_aur; return; fi ;; esac install_appimage } TMP="" cleanup() { [ -n "$TMP" ] && rm -rf "$TMP"; } trap cleanup EXIT INT TERM download() { TMP="$(mktemp -d)" say "Downloading Sajilo ($1)..." curl -fL --progress-bar -o "$TMP/$2" "$SITE/dl/$1" || fail "the download failed. Check your connection and try again." } need_root() { [ "$(id -u)" -eq 0 ] || [ -n "$SUDO" ] || fail "installing the package needs root, and sudo isn't available. Run this as root, or get the AppImage from $SITE" } install_deb() { need_root download linux-deb Sajilo-linux-amd64.deb say "Installing with apt..." # apt installs from a local file only when the path has a slash in it. $SUDO apt-get install -y "$TMP/Sajilo-linux-amd64.deb" done_message } install_rpm() { need_root download linux-rpm Sajilo-linux-x86_64.rpm if has dnf; then say "Installing with dnf..." $SUDO dnf install -y "$TMP/Sajilo-linux-x86_64.rpm" else say "Installing with zypper..." $SUDO zypper --non-interactive install --allow-unsigned-rpm "$TMP/Sajilo-linux-x86_64.rpm" fi done_message } # Whether sajilo-bin is actually on the AUR. If it isn't (never published, or # taken down), asking yay/paru for it only ends in "could not find all required # packages", so Arch falls through to the AppImage instead. aur_has_sajilo() { curl -fsSL --max-time 10 "https://aur.archlinux.org/rpc/v5/info?arg%5B%5D=sajilo-bin" 2>/dev/null | grep -q '"resultcount":[1-9]' } install_aur() { helper="yay" has yay || helper="paru" say "Installing sajilo-bin from the AUR with $helper..." # Piped into sh, stdin is this script; the helper's questions need the terminal. "$helper" -S --needed sajilo-bin "$APP_DIR/applications/sajilo-desktop.desktop" </dev/null 2>&1 || true say "Installed the AppImage to $target" if ! has fusermount && ! has fusermount3; then printf '\nThe AppImage needs FUSE to run. Install it with your package manager:\n' printf ' Arch: sudo pacman -S fuse2\n Ubuntu 24.04+: sudo apt install libfuse2t64\n Others: install libfuse2\n' fi case ":$PATH:" in *":$BIN_DIR:"*) ;; *) printf '\n%s is not on your PATH, so open Sajilo from your applications menu.\n' "$BIN_DIR" ;; esac done_message } done_message() { printf '\n' say "Sajilo is installed." printf 'Open it from your applications menu. Its flag then sits in your top bar.\n' printf 'Help: %s/docs/install-linux.html\n' "$SITE" } main "$@"