#!/usr/bin/env bash # # تثبيت مقام على Linux — the short one, because Linux does not fight us here. # # There is no Gatekeeper and no SmartScreen to get past: nothing on a Linux # desktop refuses to run a binary because a company did not vouch for it. So # this script is not a workaround for anything. It does three plain jobs: # # 1. Checks the download against a SHA-256 you can read on maqademy.com — # which matters *more* here, not less, precisely because no operating # system check exists to fall back on. # 2. Installs the .deb, or puts the AppImage somewhere on your PATH. # 3. Writes a desktop entry, so مقام appears in the applications menu rather # than only in a terminal. set -euo pipefail EXPECTED="" PKG="" BIN_DIR="$HOME/.local/bin" DESKTOP_DIR="$HOME/.local/share/applications" say() { printf '%s\n' "$*"; } die() { printf '\n✗ %s\n' "$*" >&2; exit 1; } usage() { cat <<'EOF' الاستعمال: ./install-linux.sh [مسار الملف] [--sha256 <البصمة>] يقبل ملف ‎.AppImage‎ أو ‎.deb‎ البصمة منشورة على https://maqademy.com/download EOF } while [[ $# -gt 0 ]]; do case "$1" in --sha256) EXPECTED="${2:-}"; shift 2 ;; -h|--help) usage; exit 0 ;; *) PKG="$1"; shift ;; esac done # ── 1. Find the download ───────────────────────────────────────────────────── if [[ -z "$PKG" ]]; then # Newest match wins, across both package kinds. PKG="$(ls -t "$HOME/Downloads"/Maqam*.AppImage "$HOME/Downloads"/*maqam*.deb 2>/dev/null | head -1 || true)" fi [[ -n "$PKG" && -f "$PKG" ]] || die "لم أجد ملف التثبيت. مرّر مساره: ./install-linux.sh ~/Downloads/Maqam....AppImage" say "الملف: $PKG" # ── 2. Verify, or refuse to pretend we did ─────────────────────────────────── ACTUAL="$(sha256sum "$PKG" | awk '{print $1}')" if [[ -z "$EXPECTED" ]]; then say "" say "⚠ لم تُمرَّر بصمة للتحقق." say " بصمة هذا الملف: $ACTUAL" say " قارنها بالمنشورة على https://maqademy.com/download" say "" printf " أكملُ رغم ذلك؟ [y/N] " read -r ans "$DESKTOP_DIR/maqam.desktop" </dev/null || true say "" say "✓ تمّ التثبيت: $TARGET" say " ابحث عن «Maqam» في قائمة التطبيقات." # Said only in the AppImage branch, because the .deb declares its # dependencies and apt resolves them; an AppImage bundles most of its # world but still reaches out for the system webkit. if ! ldconfig -p 2>/dev/null | grep -q webkit2gtk; then say "" say "⚠ لم أجد webkit2gtk على النظام. إن لم يفتح التطبيق:" say " Debian/Ubuntu: sudo apt install libwebkit2gtk-4.1-0" say " Fedora: sudo dnf install webkit2gtk4.1" fi # FUSE is what mounts an AppImage. Without it the file exists, is # executable, and still refuses to start — with an error that names # neither FUSE nor the fix. if ! command -v fusermount >/dev/null 2>&1 && ! command -v fusermount3 >/dev/null 2>&1; then say "" say "⚠ لم أجد FUSE. إن ظهر خطأ عند التشغيل:" say " sudo apt install libfuse2" say " أو شغّله بدونها: $TARGET --appimage-extract-and-run" fi ;; *) die "نوع ملف غير معروف. أتوقّع ‎.AppImage‎ أو ‎.deb‎" ;; esac say "" say " ملاحظة: هذه نسخة غير موقّعة. البصمة أعلاه هي ما يثبت مصدرها."