#!/bin/sh # # Rune Launcher Linux Installer # https://rune-launcher.com # set -eu deb_url='https://downloads.rune-launcher.com/releases/0.4.6/deb/Rune_0.4.6_amd64.deb' deb_filename='Rune_0.4.6_amd64.deb' deb_sha256='990499446a3182c6a954db705c221ca87054f4020e288759041e664914d83ba8' deb_arch='amd64' rpm_url='https://downloads.rune-launcher.com/releases/0.4.6/rpm/Rune-0.4.6-1.x86_64.rpm' rpm_filename='Rune-0.4.6-1.x86_64.rpm' rpm_sha256='0683f51b3d599e563979efef51319ffecad2fa0132917ff7a568aa21662e8f62' rpm_arch='amd64' manual_download_url='https://rune-launcher.com/download' support_url='https://discord.rune-launcher.com' launcher_executable='rune' desktop_entry_id='Rune.desktop' temporary_directory='' current_uid='' original_user='' say() { printf '%s\n' "$1" } fail() { printf '\nError: %s\n' "$1" >&2 printf 'Manual downloads: %s\n' "$manual_download_url" >&2 printf 'Support: %s\n' "$support_url" >&2 exit 1 } unsupported_architecture() { printf '\nRune Launcher does not currently provide a Linux package for architecture: %s\n' "$1" >&2 printf 'Manual downloads: %s\n' "$manual_download_url" >&2 exit 1 } unsupported_distribution() { printf '\nYour Linux distribution is not currently supported by the automatic installer.\n' >&2 printf 'You can download the DEB or RPM package manually:\n%s\n' "$manual_download_url" >&2 exit 1 } cleanup() { exit_status="$?" trap - EXIT HUP INT TERM if [ -n "$temporary_directory" ] && [ -d "$temporary_directory" ]; then rm -rf -- "$temporary_directory" 2>/dev/null || : fi exit "$exit_status" } has_command() { command -v "$1" >/dev/null 2>&1 } normalize_architecture() { case "$1" in x86_64|amd64) printf '%s\n' 'amd64' ;; aarch64|arm64) printf '%s\n' 'arm64' ;; *) return 1 ;; esac } classify_distribution() { distribution_id="$1" distribution_like="$2" apt_available="$3" dnf_available="$4" yum_available="$5" zypper_available="$6" distribution_identifiers=" $distribution_id $distribution_like " case "$distribution_identifiers" in *" debian "*|*" ubuntu "*|*" linuxmint "*|*" pop "*|*" pop_os "*|*" elementary "*|*" zorin "*|*" kali "*) printf '%s\n' 'deb' return 0 ;; *" opensuse "*|*" opensuse-leap "*|*" opensuse-tumbleweed "*|*" suse "*|*" sles "*|*" sled "*) printf '%s\n' 'rpm-suse' return 0 ;; *" fedora "*|*" rhel "*|*" rocky "*|*" almalinux "*|*" centos "*|*" nobara "*) printf '%s\n' 'rpm' return 0 ;; esac if [ "$apt_available" -eq 1 ]; then printf '%s\n' 'deb' elif [ "$zypper_available" -eq 1 ]; then printf '%s\n' 'rpm-suse' elif [ "$dnf_available" -eq 1 ] || [ "$yum_available" -eq 1 ]; then printf '%s\n' 'rpm' else return 1 fi } read_os_release_value() { requested_key="$1" while IFS='=' read -r current_key current_value; do [ "$current_key" = "$requested_key" ] || continue case "$current_value" in \"*\") current_value="${current_value#\"}"; current_value="${current_value%\"}" ;; \'*\') current_value="${current_value#\'}"; current_value="${current_value%\'}" ;; esac printf '%s\n' "$current_value" return 0 done < /etc/os-release return 1 } ensure_admin_access() { if [ "$current_uid" -ne 0 ] && ! has_command sudo; then fail 'Administrative access is required. Install sudo or run the installer as root.' fi } run_as_root() { if [ "$current_uid" -eq 0 ]; then "$@" else sudo "$@" fi } install_deb_package() { package_path="$1" if has_command apt-get; then run_as_root apt-get install -y "$package_path" elif has_command apt; then run_as_root apt install -y "$package_path" else return 1 fi } install_rpm_package() { package_path="$1" rpm_flavor="$2" if [ "$rpm_flavor" = 'suse' ]; then has_command zypper || return 1 run_as_root zypper --non-interactive install "$package_path" elif has_command dnf; then run_as_root dnf install -y "$package_path" elif has_command yum; then run_as_root yum install -y "$package_path" else return 1 fi } launch_detached_as_desktop_user() { has_command nohup || return 1 if [ "$current_uid" -eq 0 ]; then if [ -z "$original_user" ] || [ "$original_user" = 'root' ] || ! has_command runuser; then return 1 fi original_user_uid="$(id -u "$original_user" 2>/dev/null)" || return 1 runtime_directory="/run/user/$original_user_uid" session_bus="${DBUS_SESSION_BUS_ADDRESS:-}" if [ -S "$runtime_directory/bus" ]; then session_bus="unix:path=$runtime_directory/bus" fi nohup runuser -u "$original_user" -- env \ "DISPLAY=${DISPLAY:-}" \ "WAYLAND_DISPLAY=${WAYLAND_DISPLAY:-}" \ "DBUS_SESSION_BUS_ADDRESS=$session_bus" \ "XDG_RUNTIME_DIR=$runtime_directory" \ "$@" >/dev/null 2>&1 & else nohup "$@" >/dev/null 2>&1 & fi } launch_rune() { say 'Rune Launcher was installed successfully.' if [ -n "${SSH_CONNECTION:-}${SSH_TTY:-}${CI:-}" ] || [ -f /.dockerenv ] || \ { [ -z "${DISPLAY:-}" ] && [ -z "${WAYLAND_DISPLAY:-}" ]; }; then say 'Open Rune Launcher from your applications menu.' return 0 fi say 'Launching Rune Launcher...' installed_executable="$(command -v "$launcher_executable" 2>/dev/null || :)" if [ -n "$installed_executable" ] && [ -x "$installed_executable" ] && \ launch_detached_as_desktop_user "$installed_executable"; then return 0 fi if has_command gtk-launch && launch_detached_as_desktop_user gtk-launch "$desktop_entry_id"; then return 0 fi say 'Open Rune Launcher from your applications menu.' } main() { say 'Rune Launcher Linux Installer' say 'Detecting your system...' machine_architecture="$(uname -m)" normalized_architecture="$(normalize_architecture "$machine_architecture")" || \ unsupported_architecture "$machine_architecture" [ -r /etc/os-release ] || unsupported_distribution distribution_id="$(read_os_release_value ID 2>/dev/null || printf '%s' 'unknown')" distribution_like="$(read_os_release_value ID_LIKE 2>/dev/null || :)" distribution_name="$(read_os_release_value PRETTY_NAME 2>/dev/null || printf '%s' "$distribution_id")" distribution_id="$(printf '%s' "$distribution_id" | tr '[:upper:]' '[:lower:]')" distribution_like="$(printf '%s' "$distribution_like" | tr '[:upper:]' '[:lower:]')" apt_available=0 dnf_available=0 yum_available=0 zypper_available=0 if has_command apt-get || has_command apt; then apt_available=1; fi if has_command dnf; then dnf_available=1; fi if has_command yum; then yum_available=1; fi if has_command zypper; then zypper_available=1; fi distribution_family="$(classify_distribution \ "$distribution_id" "$distribution_like" "$apt_available" \ "$dnf_available" "$yum_available" "$zypper_available")" || unsupported_distribution case "$distribution_family" in deb) package_type='deb' package_url="$deb_url" package_filename="$deb_filename" package_sha256="$deb_sha256" package_architecture="$deb_arch" rpm_flavor='' say "Detected $distribution_name (DEB-based)." ;; rpm-suse) package_type='rpm' package_url="$rpm_url" package_filename="$rpm_filename" package_sha256="$rpm_sha256" package_architecture="$rpm_arch" rpm_flavor='suse' say "Detected $distribution_name (RPM-based)." ;; rpm) package_type='rpm' package_url="$rpm_url" package_filename="$rpm_filename" package_sha256="$rpm_sha256" package_architecture="$rpm_arch" rpm_flavor='generic' say "Detected $distribution_name (RPM-based)." ;; *) unsupported_distribution ;; esac [ "$normalized_architecture" = "$package_architecture" ] || \ unsupported_architecture "$machine_architecture" case "$package_type:$package_filename" in deb:*.deb|rpm:*.rpm) ;; *) fail 'The selected package has an unexpected file extension.' ;; esac [ -n "$package_sha256" ] || fail 'The release does not provide a package checksum.' has_command sha256sum || fail 'sha256sum is required to verify this package.' temporary_directory="$(mktemp -d)" || fail 'Could not create a temporary directory.' trap cleanup EXIT trap 'exit 129' HUP trap 'exit 130' INT trap 'exit 143' TERM package_path="$temporary_directory/$package_filename" say 'Downloading Rune Launcher...' curl -fL --retry 3 --connect-timeout 15 --output "$package_path" "$package_url" || \ fail 'Could not download the Rune Launcher package.' [ -s "$package_path" ] || fail 'The downloaded Rune Launcher package is empty.' say 'Verifying package...' checksum_output="$(sha256sum "$package_path")" actual_sha256="${checksum_output%% *}" [ "$actual_sha256" = "$package_sha256" ] || fail 'Package checksum verification failed.' if [ "$package_type" = 'deb' ]; then chmod 755 "$temporary_directory" chmod 644 "$package_path" fi current_uid="$(id -u)" if [ "$current_uid" -eq 0 ]; then original_user="${SUDO_USER:-}" else original_user="$(id -un)" fi ensure_admin_access say 'Installing Rune Launcher...' if [ "$package_type" = 'deb' ]; then install_deb_package "$package_path" || fail 'APT could not install Rune Launcher.' else install_rpm_package "$package_path" "$rpm_flavor" || \ fail 'No supported RPM package manager could install Rune Launcher.' fi launch_rune } main "$@"