#!/bin/sh # Installs XBLAH's Modding Tool on Linux, without root: # # curl -fsSL https://xblah.dev/modding-tool/install | sh # # It downloads the AppImage to ~/.local/share/XBLAH/ModdingTool/, adds it to the applications # menu and the desktop, and starts it. Run it again to reinstall; the tool updates itself. # # Options, after `sh -s --`: # --no-desktop-shortcut only the applications menu entry # --no-launch do not start the tool afterwards # --uninstall remove the menu entries and the AppImage (your settings stay) set -eu url='https://github.com/xblah-software/modding-tool-v3/releases/download/v3.0.21/XBLAHsModdingTool.AppImage' version='v3.0.21' releases='https://github.com/xblah-software/modding-tool-v3/releases/tag/v3.0.21' shortcut=--desktop-shortcut launch=1 uninstall=0 for arg in "$@"; do case "$arg" in --no-desktop-shortcut) shortcut= ;; --no-launch) launch=0 ;; --uninstall) uninstall=1 ;; *) echo "Unknown option: $arg" >&2; exit 2 ;; esac done # The same folder the tool keeps its settings in. data="${XDG_DATA_HOME:-$HOME/.local/share}" case "$data" in /*) ;; *) data="$HOME/.local/share" ;; esac dir="$data/XBLAH/ModdingTool" file="$dir/XBLAHsModdingTool.AppImage" if [ "$uninstall" = 1 ]; then if [ -x "$file" ]; then "$file" --uninstall || true rm -f "$file" echo "XBLAH's Modding Tool is uninstalled. Your settings stay in $dir." else echo "XBLAH's Modding Tool is not installed in $dir." fi exit 0 fi if [ "$(uname -s)" != Linux ] || [ "$(uname -m)" != x86_64 ]; then echo "XBLAH's Modding Tool runs on 64-bit (x86_64) Linux; this is $(uname -s) $(uname -m)." >&2 exit 1 fi if [ -z "$url" ]; then echo "The latest release has no Linux download yet. See $releases" >&2 exit 1 fi mkdir -p "$dir" part="$file.download" trap 'rm -f "$part"' EXIT echo "Downloading XBLAH's Modding Tool $version..." if command -v curl >/dev/null 2>&1; then curl -fL --progress-bar -o "$part" "$url" elif command -v wget >/dev/null 2>&1; then wget -q --show-progress -O "$part" "$url" else echo "Install curl or wget, then run this again." >&2 exit 1 fi chmod +x "$part" # A copy that is running keeps its own file open: replacing it is safe. mv -f "$part" "$file" if ! "$file" --install $shortcut; then echo "The AppImage could not install itself (see above). If it says FUSE is missing, install your distribution's fuse3 package and run this again." >&2 exit 1 fi if [ "$launch" = 1 ] && { [ -n "${DISPLAY:-}" ] || [ -n "${WAYLAND_DISPLAY:-}" ]; }; then echo "Starting it. Next time, open it from your applications menu." nohup "$file" >/dev/null 2>&1 & else echo "Open it from your applications menu." fi