Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475#!/bin/bashset -euo pipefailcd "$(dirname "$0")/.."source Scripts/remote-sync.shif [[ $# -lt 1 || $# -gt 2 ]]; then printf 'Usage: %s <host> [--dry-run|--check|--apply]\n' "$0" >&2 exit 2fihost=$1mode=${2:---dry-run}remote_validate_host "$host"case "$mode" in --dry-run|--check|--apply) ;; *) printf 'Unknown setup mode: %s\n' "$mode" >&2; exit 2 ;; esacprintf 'Bench host: %s; mode: %s\n' "$host" "$mode"printf '%s\n' \ 'Use a dedicated logged-in console user, AC power, and a deliberately selected Xcode/Swift toolchain.' \ 'Proposed AC settings: sudo pmset -c sleep 0 displaysleep 0 powernap 0 lowpowermode 0' \ 'Proposed backup exclusion: sudo tmutil addexclusion ~/parcel-ci' \ 'Manual: put ~/parcel-ci in Spotlight Privacy (do not disable indexing on the whole boot volume).' \ 'Manual: grant Accessibility to the remote build/Parcel.app, then run PARCEL_E2E_PREFLIGHT_ONLY=1 Scripts/test-e2e.sh.' \ 'Optional manual sudoers policy: permit only /usr/bin/powermetrics and /usr/bin/leaks for this user; review it with visudo.' \ 'No permission grants, toolchain selection, or sudoers changes are automated.'[[ $mode != --dry-run ]] || exit 0# shellcheck disable=SC2029ssh "$host" "bash -s -- $mode" <<'REMOTE'set -euo pipefailmode=$1console_user=$(stat -f %Su /dev/console)[[ $console_user == "$(id -un)" ]] || { printf 'Bench user is not the logged-in console user.\n' >&2; exit 2; }sw_versxcode-select -pswift --versionbattery=$(pmset -g batt)printf '%s\n' "$battery"[[ $battery == *"Now drawing from 'AC Power'"* ]] || { printf 'AC power is required.\n' >&2; exit 2; }pmset -g thermif [[ $mode == --apply ]]; then mkdir -p "$HOME/parcel-ci" sudo pmset -c sleep 0 displaysleep 0 powernap 0 lowpowermode 0 sudo tmutil addexclusion "$HOME/parcel-ci"fisettings=$(pmset -g custom)printf '%s\n' "$settings"in_ac=0seen_ac=0sleep_value= displaysleep_value= powernap_value= lowpowermode_value= powermode_value=while IFS= read -r line; do if [[ $line =~ ^AC\ Power:[[:space:]]*$ ]]; then in_ac=1; seen_ac=1; continue; fi if [[ $line =~ ^[^[:space:]] ]]; then in_ac=0; fi [[ $in_ac == 1 ]] || continue if [[ $line =~ ^[[:space:]]*([[:alnum:]_]+)[[:space:]]+([0-9]+)[[:space:]]*$ ]]; then key=${BASH_REMATCH[1]} value=${BASH_REMATCH[2]} case "$key" in sleep) sleep_value=$value ;; displaysleep) displaysleep_value=$value ;; powernap) powernap_value=$value ;; lowpowermode) lowpowermode_value=$value ;; powermode) powermode_value=$value ;; esac fidone <<< "$settings"[[ $seen_ac == 1 ]] || { printf 'Missing AC power settings\n' >&2; exit 1; }for key in sleep displaysleep powernap; do variable="${key}_value" [[ ${!variable} == 0 ]] || { printf 'Unexpected AC setting: %s\n' "$key" >&2; exit 1; }done[[ -n $lowpowermode_value || -n $powermode_value ]] || { printf 'Low Power Mode must be off\n' >&2; exit 1; }for value in "$lowpowermode_value" "$powermode_value"; do [[ -z $value || $value == 0 || $value == 2 ]] || { printf 'Low Power Mode must be off\n' >&2; exit 1; }doneexclusion=$(tmutil isexcluded "$HOME/parcel-ci")printf '%s\n' "$exclusion"[[ $exclusion == *'[Excluded]'* ]] || { printf 'Backup exclusion is not active.\n' >&2; exit 2; }printf 'AC settings and backup exclusion verified; Accessibility and Spotlight remain manual preflight requirements.\n'REMOTE