#!/usr/bin/env bash # Installs PrayerLock 1.1 from https://apps.abrarzahin.com/ on a Mac or on Ubuntu/Debian Linux. # # curl -fsSL https://apps.abrarzahin.com/prayerlock.sh | bash # # What it does, in order: # 1. downloads the same file the download page offers (PrayerLock.dmg on a Mac, prayerlock_amd64.deb on Linux) # 2. checks its SHA-256 against the one below, and stops if it differs # 3. Mac: copies PrayerLock.app into /Applications (or ~/Applications) and opens it # Linux: installs the .deb with apt (asks for your password) and opens it # A file downloaded by a browser gets a "downloaded from the internet" mark, which is what makes # macOS refuse an app that isn't notarized by Apple. curl doesn't add that mark, so the app opens # normally. Nothing else on your system is changed. # # Optional: INSTALL_DIR=/some/folder puts the Mac app there; NO_OPEN=1 skips opening it. set -euo pipefail APP="PrayerLock" SLUG="prayerlock" TMP="" BASE="https://apps.abrarzahin.com" MAC_SHA="5d1cdc78a585451979d60ded6102b0f4d5a764249676d68e3132d3e433dccebc" LINUX_SHA="dd21b168d7c4c1d935d96a924711cdc22230d81bcaf47b17a67e10512235a669" say() { printf '\033[1m%s\033[0m\n' "$*"; } fail() { printf '\033[31mError:\033[0m %s\n' "$*" >&2; exit 1; } # download URL FILE SHA256 download() { say "Downloading $(basename "$2")..." curl -fL --progress-bar -o "$2" "$1" || fail "couldn't download $1. Check your internet connection and try again." local got if command -v shasum >/dev/null; then got=$(shasum -a 256 "$2"); else got=$(sha256sum "$2"); fi [ "${got%% *}" = "$3" ] || fail "the download doesn't match the file published on abrarzahin.com, so nothing was installed. Try again in a few minutes." } install_mac() { local dest mnt TMP=$(mktemp -d) trap 'hdiutil detach -quiet "$TMP/mnt" 2>/dev/null || true; rm -rf "$TMP"' EXIT download "$BASE/$APP.dmg" "$TMP/$APP.dmg" "$MAC_SHA" mnt="$TMP/mnt" mkdir "$mnt" hdiutil attach -quiet -nobrowse -readonly -mountpoint "$mnt" "$TMP/$APP.dmg" 2>"$TMP/attach.log" \ || { cat "$TMP/attach.log" >&2; fail "couldn't open the downloaded disk image."; } dest="${INSTALL_DIR:-/Applications}" if [ -z "${INSTALL_DIR:-}" ] && [ ! -w /Applications ]; then dest="$HOME/Applications"; fi mkdir -p "$dest" say "Installing $APP into $dest..." # a running copy keeps going and switches to the new version by itself when it's idle rm -rf "$dest/$APP.app" ditto "$mnt/$APP.app" "$dest/$APP.app" hdiutil detach -quiet "$mnt" || true if [ "${NO_OPEN:-}" != 1 ]; then say "Opening $APP..." open "$dest/$APP.app" fi say "Done. $APP is installed in $dest." } install_linux() { command -v apt-get >/dev/null || fail "this installer needs Ubuntu or Debian (apt). See $BASE/ for other options." [ "$(dpkg --print-architecture)" = amd64 ] || fail "$APP for Linux is only built for 64-bit Intel/AMD computers for now." TMP=$(mktemp -d) trap 'rm -rf "$TMP"' EXIT chmod 755 "$TMP" # apt reads the file as its own user download "$BASE/${SLUG}_amd64.deb" "$TMP/${SLUG}_amd64.deb" "$LINUX_SHA" chmod 644 "$TMP/${SLUG}_amd64.deb" say "Installing $APP (sudo asks for your password)..." sudo apt-get install -y "$TMP/${SLUG}_amd64.deb" if [ "${NO_OPEN:-}" != 1 ] && [ -n "${DISPLAY:-}${WAYLAND_DISPLAY:-}" ]; then say "Opening $APP..." nohup "$SLUG" >/dev/null 2>&1 & fi say "Done. $APP is installed; open it from your app launcher any time." } main() { case "$(uname -s)" in Darwin) install_mac ;; Linux) install_linux ;; *) fail "this installer is for Mac and Linux. On Windows, open PowerShell and run: irm $BASE/$SLUG.ps1 | iex" ;; esac } # everything above only defines functions, so a cut-off download can't run half a script main "$@"