#!/usr/bin/env bash set -euo pipefail PATH=/usr/bin:/bin:/usr/sbin:/sbin export PATH umask 077 BASE=https://download.azure.cx VERIFY_ONLY=0 DRY=0 ROLLBACK=0 BLUE=''; GREEN=''; RED=''; RESET='' if { [ -t 1 ] || [ "${CLICOLOR_FORCE:-0}" = 1 ]; } && [ -z "${NO_COLOR:-}" ]; then BLUE=$'\033[36m'; GREEN=$'\033[32m'; RED=$'\033[31m'; RESET=$'\033[0m' fi for arg in "$@"; do case "$arg" in --verify-only) VERIFY_ONLY=1 ;; --dry-run) DRY=1 ;; --rollback) ROLLBACK=1 ;; --no-launch|--keep-backup) ;; -h|--help) echo 'usage: install.sh [--verify-only] [--dry-run] [--no-launch] [--keep-backup] [--rollback]' exit 0 ;; *) echo "install: unknown argument $arg" >&2; exit 2 ;; esac done die() { printf '%s[✗] %s%s\n' "$RED" "$*" "$RESET" >&2; exit 1; } step() { printf '\n%s==> %s%s\n' "$BLUE" "$*" "$RESET"; } ok() { printf '%s[✓] %s%s\n' "$GREEN" "$*" "$RESET"; } [ "$ROLLBACK" = 0 ] || [ "$VERIFY_ONLY" = 0 ] || die '--rollback and --verify-only cannot be combined' [ "$(uname -s)" = Darwin ] || die 'macOS required' [ "$(id -u)" != 0 ] || die 'Run as your normal macOS user, without sudo' MAJOR="$(sw_vers -productVersion | cut -d. -f1)" [[ "$MAJOR" =~ ^[0-9]+$ ]] && [ "$MAJOR" -ge 13 ] || die 'macOS 13 or later required' for tool in curl openssl shasum tar ditto codesign security plutil; do command -v "$tool" >/dev/null || die "Required system tool missing: $tool" done WORK="$(mktemp -d "${TMPDIR:-/tmp}/azure-install.XXXXXX")" LOCK='' cleanup() { local result=$? [ "$result" = 0 ] || printf '%s[✗] Installer failed%s\n' "$RED" "$RESET" >&2 rm -rf "$WORK" [ -z "$LOCK" ] || rmdir "$LOCK" 2>/dev/null || true exit "$result" } trap cleanup EXIT trap 'exit 130' INT trap 'exit 143' TERM [ "$(df -Pk "$WORK" | awk 'NR==2 {print $4}')" -ge 3145728 ] || die 'At least 3 GiB of free disk space required' printf '%s' "$BLUE" cat <<'BANNER' _ / \ ___ _ _ _ __ ___ / _ \ |_ / | | | '__/ _ \ / ___ \ / /| |_| | | | __/ /_/ \_/___|\__,_|_| \___| BANNER printf 'Azure macOS installer%s\n' "$RESET" fetch() { local progress=--silent [ ! -t 2 ] || progress=--progress-bar curl --fail --show-error "$progress" --location --retry 2 --connect-timeout 15 --max-time 900 \ --proto '=https' --proto-redir '=https' --tlsv1.2 "$1" -o "$2" } cat > "$WORK/release-public.pem" <<'AZURE_RELEASE_PUBLIC_KEY' -----BEGIN PUBLIC KEY----- MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEApkAnV1MrMTisRQWflVOY F3R1T4lNBzTmRqqSMyG33L1wLjfFGbaBFVRAq45u3SgkR3xMtX/UZcUJ06cQuVhm Wy60GIGs51W/oClwVKip8Z44isFfd0RTrAC0Mv10kbtjlTFyEAperurRRqxhmCAr 60imsWPGO5aKCULNZJKtNAoJDj9dMTb6Cci5hEbowS+iQeRHTgMQNJzxeZ+lITcz vZRRtca0724lY+ItAsvX1r3TsmYrD6PCcT816AX6wUwK/vRbBNl46rfYfco4iDKN fyF2QPTaNx+Jz8bODGOYH1/nGW6y/cD0JVT5m5h0VNnc/TOwvymwHHAm7vUmC4Lg oKFy83HO3OSFYwoH9EwNrjJ3ADlv6BZQIopkH9JZBd8SQQ0AdoFWJG6FAEjoSy7s tOp1avwKsE+l9LNo+yOVb4aFWMhgKDUwZJLafmDQGZFQ22uiKazPuqE442DsDq0z TEbNYBvLIBhE09gpI1wOU6DRAvxu7Vc2uJKf/Dyznr31AgMBAAE= -----END PUBLIC KEY----- AZURE_RELEASE_PUBLIC_KEY step 'Checking latest release' fetch "$BASE/stable/manifest.json" "$WORK/manifest.json" field() { plutil -extract "$1" raw -o - "$WORK/manifest.json"; } RELEASE="$(field release)" [[ "$RELEASE" =~ ^[0-9][0-9A-Za-z._+-]{0,63}$ ]] || die 'Invalid release identifier' fetch "$BASE/releases/$RELEASE/manifest.sig" "$WORK/manifest.sig" openssl dgst -sha256 -verify "$WORK/release-public.pem" -signature "$WORK/manifest.sig" "$WORK/manifest.json" >/dev/null 2>&1 || die 'Release signature verification failed; no apps changed' [ "$(field schema)" = 1 ] || die 'Unsupported release manifest' URL="$(field artifact.url)" case "$URL" in "$BASE/releases/$RELEASE/Azure-macos-universal.tar.xz") ARCHIVE=Azure.tar.xz ;; "$BASE/releases/$RELEASE/Azure-macos-universal.zip") ARCHIVE=Azure.zip ;; *) die 'Invalid release download URL' ;; esac SHA256="$(field artifact.sha256)" NATIVE_SHA256="$(field artifact.native_sha256)" SIZE="$(field artifact.size)" [[ "$SHA256" =~ ^[0-9a-f]{64}$ && "$NATIVE_SHA256" =~ ^[0-9a-f]{64}$ && "$SIZE" =~ ^[1-9][0-9]{0,9}$ ]] || die 'Invalid release metadata' [ "$SIZE" -le 2147483648 ] || die 'Release archive is too large' MINIMUM="$(field min_macos)" [[ "$MINIMUM" =~ ^[0-9]+$ ]] && [ "$MAJOR" -ge "$MINIMUM" ] || die 'This release needs a newer macOS version' ok 'Release verified' step "Downloading Azure $(field version)" fetch "$URL" "$WORK/$ARCHIVE" [ "$(stat -f %z "$WORK/$ARCHIVE")" = "$SIZE" ] || die 'Download size mismatch; no apps changed' ACTUAL="$(shasum -a 256 "$WORK/$ARCHIVE")" [ "${ACTUAL%% *}" = "$SHA256" ] || die 'Download checksum mismatch; no apps changed' ok 'Download complete' step 'Verifying download' mkdir "$WORK/payload" if [ "$ARCHIVE" = Azure.tar.xz ]; then tar -xJf "$WORK/$ARCHIVE" -C "$WORK/payload" else ditto -x -k "$WORK/$ARCHIVE" "$WORK/payload" fi APP="$WORK/payload/Azure.app" [ -d "$APP" ] && [ ! -L "$APP" ] || die 'Release archive has no Azure.app' [ "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$APP/Contents/Info.plist")" = com.azure.executor ] || die 'Wrong application identifier' [ "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")" = "$(field version)" ] || die 'Application version differs from manifest' codesign --verify --all-architectures --deep --strict "$APP" || die 'Application signature is invalid' ACTUAL="$(shasum -a 256 "$APP/Contents/Resources/azure.node")" [ "${ACTUAL%% *}" = "$NATIVE_SHA256" ] || die 'Native payload differs from manifest' [ -f "$APP/Contents/Resources/installer/scripts/install-local.sh" ] || die 'Release installer is missing' ok 'Download verified' if [ "$VERIFY_ONLY" = 1 ]; then ok 'Download verified; no changes made' exit 0 fi . "$APP/Contents/Resources/installer/scripts/install-common.sh" azure_select_paths "$ROLLBACK" DEST="$AZURE_APP_DEST" if [ "$DRY" = 0 ]; then mkdir -p "$(dirname "$DEST")" "$(dirname "$AZURE_ROBLOX_APP")"; fi [ "$DRY" = 1 ] || [ -w "$(dirname "$DEST")" ] || die 'Application directory is not writable by this user' [ ! -L "$DEST" ] || die 'Installed Azure.app cannot be a symlink' [ ! -e "$DEST" ] || [ -d "$DEST" ] || die 'Application destination is not a directory' DISK="$(dirname "$DEST")"; [ -d "$DISK" ] || DISK="$HOME" [ "$(df -Pk "$DISK" | awk 'NR==2 {print $4}')" -ge 3145728 ] || die 'Application disk needs at least 3 GiB free' LOCK_ROOT="$HOME/Library/Application Support/Azure" mkdir -p "$LOCK_ROOT" mkdir "$LOCK_ROOT/.install-lock" 2>/dev/null || die "Another install is running; stale lock can be removed at $LOCK_ROOT/.install-lock after it stops" LOCK="$LOCK_ROOT/.install-lock" if [ "$ROLLBACK" = 1 ]; then step 'Restoring official Roblox'; else step 'Installing Azure'; fi AZURE_BUILD_DIR="$WORK/payload" bash "$APP/Contents/Resources/installer/scripts/install-local.sh" "$@" if [ "$DRY" = 1 ]; then ok 'Preview finished; no apps changed' elif [ "$ROLLBACK" = 1 ]; then ok 'Official Roblox restored' else ok 'Azure installed successfully'; fi