From dc8254aa81b042fe556ab56b76eddf217df9b6f5 Mon Sep 17 00:00:00 2001 From: Christoph von Gabler-Sahm Date: Tue, 17 May 2022 17:05:14 +0200 Subject: [PATCH] Fix for Issue #225: Use sysctl to check for ARM, and fall back to arch if no ARM detected. --- erase-install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erase-install.sh b/erase-install.sh index df11fab..35eb06d 100755 --- a/erase-install.sh +++ b/erase-install.sh @@ -1948,7 +1948,9 @@ fi # Silicon Macs require a username and password to run startosinstall # We therefore need to be logged in to proceed, if we are going to erase or reinstall # This goes before the download so users aren't waiting for the prompt for username -arch=$(/usr/bin/arch) +# Check for Apple Silicon using sysctl, because arch will not report arm64 if running under Rosetta. +[[ $(/usr/sbin/sysctl -q -n "hw.optional.arm64") -eq 1 ]] && arch="arm64" || arch=$(/usr/bin/arch) +echo " [$script_name] Running on architecture $arch" if [[ "$arch" == "arm64" && ($erase == "yes" || $reinstall == "yes") ]]; then if ! pgrep -q Finder ; then echo " [$script_name] ERROR! The startosinstall binary requires a user to be logged in."