#!/bin/zsh # Remolo Helper — install from Terminal. # # curl -fsSL https://remolo.app/install.sh | zsh # curl -fsSL https://remolo.app/install.sh | zsh -s -- --dry-run (check everything, install nothing) # # What it does, in order: # 1. downloads the current Remolo Helper disk image from remolo.app; # 2. checks its SHA-256, mounts it read-only and checks the app's code signature (our Developer ID) # and Apple's notarization (Gatekeeper); # 3. copies Remolo Helper to /Applications (asks for your password only if that folder isn't writable for you), # unmounts the image and deletes the download; # 4. opens Remolo Helper and the three privacy panes it needs in System Settings. # macOS never lets a script grant Accessibility, Screen Recording or Local Network: you switch them on yourself. # Read before you run: https://remolo.app/install.sh — nothing here is piped to sudo. # zsh only (the default shell on every Mac this supports). if [ -z "${ZSH_VERSION:-}" ]; then echo "Run it with zsh: curl -fsSL https://remolo.app/install.sh | zsh" >&2 exit 2 fi # The temporary folder and mount point live outside main() so the exit trap still sees them. REMOLO_TMP="" REMOLO_MNT="" remolo_cleanup() { if [[ -n "$REMOLO_MNT" && -d "$REMOLO_MNT" ]]; then hdiutil detach -quiet "$REMOLO_MNT" 2>/dev/null || hdiutil detach -quiet -force "$REMOLO_MNT" 2>/dev/null || true fi [[ -n "$REMOLO_TMP" ]] && rm -rf "$REMOLO_TMP" REMOLO_MNT=""; REMOLO_TMP="" } # Everything runs inside main(), called on the last line, so a cut-off download does nothing. main() { set -euo pipefail # Set from inc/config.php by tools/build-static.sh on every build; keep the quotes. local VERSION="1.5.2" local SHA256="4790dd7f37c135fb12b698aa841a327a60b52532cc71f2ea87fdbb2016d1d1b8" local TEAM_ID="8LK585DZFV" local BASE_URL="${REMOLO_BASE_URL:-https://remolo.app}" local APP_NAME="Remolo Helper.app" local DEST_DIR="/Applications" local DEST="$DEST_DIR/$APP_NAME" local DRY_RUN=0 FORCE=0 OPEN_PANES=1 local arg for arg in "$@"; do case "$arg" in --dry-run|-n) DRY_RUN=1 ;; --force) FORCE=1 ;; --no-settings) OPEN_PANES=0 ;; -h|--help) print -r -- "Usage: install.sh [--dry-run] [--force] [--no-settings]" print -r -- " --dry-run download and verify Remolo Helper $VERSION, change nothing" print -r -- " --force reinstall even if the same or a newer version is installed" print -r -- " --no-settings don't open the privacy panes in System Settings" return 0 ;; *) print -u2 -r -- "Unknown option: $arg (try --help)"; return 2 ;; esac done local bold="" dim="" off="" if [[ -t 1 ]]; then bold=$'\e[1m'; dim=$'\e[2m'; off=$'\e[0m'; fi say() { print -r -- "${bold}==>${off} $*"; } note() { print -r -- " $*"; } fail() { print -u2 -r -- "Error: $*"; exit 1; } # ---------- Where we are ---------- [[ "$(uname -s)" == Darwin ]] || fail "Remolo Helper is a Mac app; this Mac isn't one." local os_major os_major="$(sw_vers -productVersion | cut -d. -f1)" (( os_major >= 15 )) || fail "Remolo Helper needs macOS 15 or later (this Mac has $(sw_vers -productVersion))." case "$BASE_URL" in https://*) ;; http://127.0.0.1:*|http://localhost:*) note "${dim}Testing against $BASE_URL${off}" ;; *) fail "Refusing to download over plain HTTP: $BASE_URL" ;; esac (( DRY_RUN )) && say "Dry run: checking everything, installing nothing." # ---------- Already installed? ---------- local installed="" if [[ -d "$DEST" ]]; then installed="$(defaults read "$DEST/Contents/Info" CFBundleShortVersionString 2>/dev/null || true)" fi local skip_copy=0 if [[ -n "$installed" && $FORCE -eq 0 ]]; then local newest newest="$(printf '%s\n%s\n' "$installed" "$VERSION" | sort -V | tail -n 1)" if [[ "$newest" == "$installed" ]]; then skip_copy=1 say "Remolo Helper $installed is already installed (this download is $VERSION)." note "It updates itself from the menu bar. Use --force to reinstall $VERSION anyway." fi fi # ---------- Download into a private temporary folder ---------- local dmg REMOLO_TMP="$(mktemp -d "${TMPDIR:-/tmp}/remolo-install.XXXXXX")" trap remolo_cleanup EXIT trap 'remolo_cleanup; exit 130' INT TERM dmg="$REMOLO_TMP/Remolo-Helper-$VERSION.dmg" local url="$BASE_URL/helper/Remolo-Helper-$VERSION.dmg" if (( skip_copy && ! DRY_RUN )); then : # nothing to download else say "Downloading Remolo Helper $VERSION" note "${dim}$url${off}" curl --fail --location --silent --show-error --proto '=https,http' --retry 2 -o "$dmg" "$url" \ || fail "The download didn't finish. Check the connection and try again, or get it from https://remolo.app/download" # ---------- Verify ---------- say "Checking the file" local got got="$(shasum -a 256 "$dmg" | awk '{print $1}')" [[ "$got" == "$SHA256" ]] || fail "SHA-256 doesn't match (got $got). Don't install it; write to support@remolo.app." note "SHA-256 matches remolo.app/download" REMOLO_MNT="$REMOLO_TMP/mnt" mkdir -p "$REMOLO_MNT" hdiutil attach -nobrowse -readonly -noautoopen -quiet -mountpoint "$REMOLO_MNT" "$dmg" \ || { REMOLO_MNT=""; fail "The disk image didn't open (it may be damaged)."; } [[ -d "$REMOLO_MNT/$APP_NAME" ]] || fail "$APP_NAME isn't in the disk image." # Check (and later install) a clean copy: Finder layout data on the bundle in the image is not part of the # signature, and codesign --strict rightly refuses any such extra attributes. local app="$REMOLO_TMP/stage/$APP_NAME" mkdir -p "$REMOLO_TMP/stage" ditto --norsrc --noextattr --noqtn "$REMOLO_MNT/$APP_NAME" "$app" hdiutil detach -quiet "$REMOLO_MNT" && REMOLO_MNT="" codesign --verify --deep --strict "$app" 2>/dev/null || fail "The app's code signature is broken. Don't install it." local team team="$(codesign -dv --verbose=2 "$app" 2>&1 | sed -n 's/^TeamIdentifier=//p')" [[ "$team" == "$TEAM_ID" ]] || fail "Signed by team '$team', not Remolo's $TEAM_ID. Don't install it." note "Signed with Developer ID: KIRIL TREITIAK ($TEAM_ID)" local assess assess="$(spctl -a -t exec -vv "$app" 2>&1 || true)" print -r -- "$assess" | grep -q "accepted" \ || fail "Gatekeeper doesn't accept the app: $assess" print -r -- "$assess" | grep -q "Notarized Developer ID" || fail "The app isn't notarized by Apple: $assess" note "Notarized by Apple, accepted by Gatekeeper" local app_version app_version="$(defaults read "$app/Contents/Info" CFBundleShortVersionString 2>/dev/null || echo "?")" [[ "$app_version" == "$VERSION" ]] || note "${dim}(the app inside reports version $app_version)${off}" # ---------- Install ---------- if (( DRY_RUN )); then say "Would install:" if (( skip_copy )); then note "nothing — Remolo Helper $installed stays as it is" else [[ -n "$installed" ]] && note "quit Remolo Helper $installed if it's running (connected phones would disconnect)" if [[ -w "$DEST_DIR" ]]; then note "copy $APP_NAME to $DEST_DIR"; else note "copy $APP_NAME to $DEST_DIR with sudo (you'd be asked for your password)"; fi note "remove the quarantine flag only if macOS set one" fi note "open Remolo Helper, then System Settings → Privacy & Security: Accessibility, Screen & System Audio Recording, Local Network" say "Dry run finished: the download is genuine. Nothing was changed." return 0 fi local SUDO=() [[ -w "$DEST_DIR" && ( ! -e "$DEST" || -w "$DEST" ) ]] || SUDO=(sudo) if pgrep -xq "Remolo Helper"; then say "Quitting the running Remolo Helper (connected phones disconnect for a moment)" osascript -e 'tell application id "app.remolo.mac" to quit' >/dev/null 2>&1 || true local i for i in {1..20}; do pgrep -xq "Remolo Helper" || break; sleep 0.5; done pgrep -xq "Remolo Helper" && fail "Remolo Helper didn't quit. Quit it from the menu bar and run this again." fi say "Copying Remolo Helper to $DEST_DIR" (( ${#SUDO} )) && note "$DEST_DIR isn't writable for you, so macOS asks for your password (sudo)." if [[ -e "$DEST" ]]; then "${SUDO[@]}" rm -rf "$DEST"; fi "${SUDO[@]}" ditto "$app" "$DEST" if xattr -p com.apple.quarantine "$DEST" >/dev/null 2>&1; then "${SUDO[@]}" xattr -dr com.apple.quarantine "$DEST" note "Removed the quarantine flag (the app is notarized and was checked above)" fi installed="$VERSION" fi if (( DRY_RUN )); then return 0; fi # ---------- Open it, then the privacy panes ---------- say "Opening Remolo Helper" open "$DEST" print say "${bold}Three permissions, once.${off} macOS lets only you switch them on — no script can." note "Remolo Helper's window walks you through them; the panes below are the same switches." local -a panes=( "Accessibility|Privacy_Accessibility|to move the pointer, click and type for your phone" "Screen & System Audio Recording|Privacy_ScreenCapture|to show the Mac's screen and sound on your phone (macOS then restarts the Helper)" "Local Network|Privacy_LocalNetwork|so your iPhone finds the Mac at home" ) local interactive=0 if (( OPEN_PANES )) && { exec 3/dev/null; then interactive=1; fi local p name anchor why n=1 for p in "${panes[@]}"; do name="${p%%|*}"; anchor="${${p#*|}%%|*}"; why="${p##*|}" note "$n. $name — turn on Remolo Helper ($why)" if (( OPEN_PANES )); then if (( interactive )); then printf ' Press Return to open it… ' local answer read -r -u 3 answer || true fi open "x-apple.systempreferences:com.apple.preference.security?$anchor" || true (( interactive )) || break # without a keyboard, open only the first pane fi n=$((n + 1)) done (( interactive )) && exec 3<&- print say "Done. Remolo Helper $installed is in $DEST_DIR." note "Next: in Remolo on your iPhone, scan the QR code in the Helper window. Help: https://remolo.app/start" } main "$@" rc=$? remolo_cleanup exit $rc