#!/usr/bin/env sh set -eu BASE_URL="https://get.muntim.ru" BIN_NAME="muntim-maui" os="$(uname -s)" arch="$(uname -m)" case "$os" in Linux) platform_os="linux" ;; Darwin) platform_os="darwin" ;; *) echo "unsupported OS: $os" >&2 exit 1 ;; esac case "$arch" in x86_64|amd64) platform_arch="amd64" ;; arm64|aarch64) platform_arch="arm64" ;; *) echo "unsupported architecture: $arch" >&2 exit 1 ;; esac tmp_dir="$(mktemp -d)" trap 'rm -rf "$tmp_dir"' EXIT download_url="$BASE_URL/downloads/${BIN_NAME}-${platform_os}-${platform_arch}" target_path="$tmp_dir/$BIN_NAME" if command -v curl >/dev/null 2>&1; then curl -fsSL "$download_url" -o "$target_path" elif command -v wget >/dev/null 2>&1; then wget -qO "$target_path" "$download_url" else echo "curl or wget is required" >&2 exit 1 fi chmod +x "$target_path" install_dir="${HOME}/.local/bin" needs_path_hint=0 if [ -w /usr/local/bin ]; then install_dir="/usr/local/bin" elif command -v sudo >/dev/null 2>&1; then sudo install -m 0755 "$target_path" "/usr/local/bin/$BIN_NAME" echo "installed to /usr/local/bin/$BIN_NAME" exit 0 else mkdir -p "$install_dir" needs_path_hint=1 fi install -m 0755 "$target_path" "$install_dir/$BIN_NAME" echo "installed to $install_dir/$BIN_NAME" case ":$PATH:" in *":$install_dir:"*) ;; *) if [ "$needs_path_hint" -eq 1 ]; then echo "add to PATH: export PATH=\"$install_dir:\$PATH\"" fi ;; esac