#!/usr/bin/env bash set -euo pipefail uninstall() { local found=0 desktopdir file local -a elevate=() files=() if [[ $(uname -s) != Linux ]]; then printf 'Bardo for Linux can only be removed on Linux.\n' >&2; return 1 fi if (( EUID != 0 )); then elevate=(sudo); fi desktopdir="${XDG_DATA_HOME:-$HOME/.local/share}/applications" printf 'If Bardo is running, quit it from its tray icon first: closing the window only hides it.\n' if command -v dpkg >/dev/null 2>&1 && dpkg -s bardo >/dev/null 2>&1; then if (( EUID != 0 )) && ! command -v sudo >/dev/null 2>&1; then printf 'sudo is required to remove the package.\n' >&2; return 1; fi printf 'Removing the Debian/Ubuntu package...\n' "${elevate[@]}" apt-get remove -y bardo found=1 fi if command -v rpm >/dev/null 2>&1 && rpm -q bardo >/dev/null 2>&1; then if (( EUID != 0 )) && ! command -v sudo >/dev/null 2>&1; then printf 'sudo is required to remove the package.\n' >&2; return 1; fi printf 'Removing the Fedora package...\n' "${elevate[@]}" dnf remove -y bardo found=1 fi if (( EUID != 0 )); then files=("$HOME"/.local/lib/bardo/Bardo_*.AppImage "$HOME/.local/bin/bardo-appimage" "$desktopdir/bardo-appimage.desktop") for file in "${files[@]}"; do if [[ -e $file ]]; then rm -f -- "$file"; printf 'Removed %s\n' "$file"; found=1; fi done rmdir "$HOME/.local/lib/bardo" 2>/dev/null || true fi if (( found )); then printf 'Bardo was removed. Your notes and settings in your user profile were not deleted.\n' else printf 'No Bardo installation from this installer or its packages was found.\n' fi } main() { local format="auto" base="https://typexai.dev/downloads/bardo-linux/0.1.4" local name hash work target manager version launcher appdir desktopdir local -a elevate=() case "${1:-}" in "") ;; --deb) format=deb ;; --rpm) format=rpm ;; --appimage) format=appimage ;; --uninstall) format=uninstall ;; --help|-h) printf 'Install Bardo Linux 0.1.4 (x86_64). Usage: bash bardo-linux-install.sh [--deb|--rpm|--appimage|--uninstall]\nPackages use apt/dnf; AppImage installs for the current user. Downloads are checked with SHA-256.\n--uninstall removes the package or the AppImage install and keeps your notes.\n' return ;; *) printf 'Unknown option: %s\n' "$1" >&2; return 1 ;; esac if (( $# > 1 )); then printf 'Pass only one option.\n' >&2; return 1; fi if [[ $format == uninstall ]]; then uninstall; return; fi if [[ $(uname -s) != Linux || $(uname -m) != x86_64 ]]; then printf 'This release requires Linux x86_64, not ARM, Windows or macOS.\n' >&2; return 1 fi for tool in curl sha256sum mktemp getconf; do if ! command -v "$tool" >/dev/null 2>&1; then printf 'Required command not found: %s. Install it with your package manager first.\n' "$tool" >&2; return 1 fi done version=$(getconf GNU_LIBC_VERSION 2>/dev/null) || { printf 'This release requires glibc 2.34 or newer (musl is not supported).\n' >&2; return 1; } version=${version##* } if [[ ! $version =~ ^([0-9]+)\.([0-9]+) ]] || (( BASH_REMATCH[1] < 2 || (BASH_REMATCH[1] == 2 && BASH_REMATCH[2] < 34) )); then printf 'This release requires glibc 2.34 or newer. Found: %s\n' "$version" >&2; return 1 fi if [[ $format == auto ]]; then if command -v apt-get >/dev/null 2>&1; then format=deb elif command -v dnf >/dev/null 2>&1; then format=rpm else format=appimage; fi fi case "$format" in deb) name=Bardo_0.1.4_amd64.deb hash=73ccf029543e5a0a2b2b32a9f819448e32c26ee58233e12e35436fee2f94b128 manager=apt-get ;; rpm) name=Bardo-0.1.4-1.x86_64.rpm hash=028a60e099cb5500df202d3a8a3f1fbfdd6b97e6032125dcc587599b3f0d2c82 manager=dnf ;; appimage) name=Bardo_0.1.4_amd64.AppImage hash=3fa333c601663242c53debbd348c350da78717d9af28da9387a8fce56b3bd9bd if (( EUID == 0 )); then printf 'Run AppImage installation as your normal desktop user, without sudo.\n' >&2; return 1 fi ;; esac if [[ $format != appimage ]]; then if ! command -v "$manager" >/dev/null 2>&1; then printf '%s is not available. Choose the matching package or --appimage.\n' "$manager" >&2; return 1 fi if (( EUID != 0 )); then if ! command -v sudo >/dev/null 2>&1; then printf 'sudo is required for package installation.\n' >&2; return 1; fi elevate=(sudo) fi fi work=$(mktemp -d) # EXIT runs after main returns, so capture the path rather than the local variable. trap "rm -rf -- '${work//\'/\'\\\'\'}'" EXIT target="$work/$name" printf 'Downloading Bardo Linux 0.1.4 (%s)...\n' "$format" curl --fail --show-error --location --proto '=https' --tlsv1.2 --retry 3 --connect-timeout 20 --output "$target" "$base/$name" if ! printf '%s %s\n' "$hash" "$target" | sha256sum --check --status; then printf 'SHA-256 verification failed. Nothing was installed.\n' >&2; return 1 fi printf 'SHA-256 verified.\n' printf 'If an older Bardo is running, quit it from its tray icon first: closing the window only hides it.\n' case "$format" in deb) # Let apt's unprivileged download helper read the local package. chmod 755 "$work" chmod 644 "$target" "${elevate[@]}" apt-get update "${elevate[@]}" apt-get install -y "$target" printf 'Bardo is installed. Open it from your application menu.\n' ;; rpm) "${elevate[@]}" dnf install -y "$target" printf 'Bardo is installed. Open it from your application menu.\n' ;; appimage) appdir="$HOME/.local/lib/bardo" desktopdir="${XDG_DATA_HOME:-$HOME/.local/share}/applications" launcher="$HOME/.local/bin/bardo-appimage" mkdir -p "$appdir" "$HOME/.local/bin" "$desktopdir" install -m 755 "$target" "$appdir/$name" # Extract-and-run avoids the FUSE dependency on modern distributions. printf '#!/usr/bin/env bash\nexec "$HOME/.local/lib/bardo/%s" --appimage-extract-and-run "$@"\n' "$name" > "$launcher" chmod 755 "$launcher" # Use a shell launcher with a stable home-relative path, not an unescaped HOME in Exec. cat > "$desktopdir/bardo-appimage.desktop" <<'DESKTOP' [Desktop Entry] Type=Application Name=Bardo Comment=Notes and tasks Exec=sh -c "exec \\"\\$HOME/.local/bin/bardo-appimage\\"" Terminal=false Categories=Office;Utility; DESKTOP printf 'Bardo is installed for this user. Open Bardo from your application menu or run:\n%s\n' "$launcher" ;; esac } main "$@"