Changed variable 'consoluser' to set after waitForDesktop function runs to prevent variable being set to the default/setup user account.
Also made a small change to check for rosetta 2 function. Checking for "/Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist" doesnt appear to work for me in Monterey, however
"/usr/bin/pgrep oahd >/dev/null 2>&1" works. Source here https://derflounder.wordpress.com/2020/11/17/installing-rosetta-2-on-apple-silicon-macs/
Changed variable 'consoluser' to set after waitForDesktop function runs to prevent variable being set to the default/setup user account. Also made a small change to check for rosetta 2 function. Checking for "/Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist" doesnt appear to work for me in Monterey, however "/usr/bin/pgrep oahd >/dev/null 2>&1" works. Source here https://derflounder.wordpress.com/2020/11/17/installing-rosetta-2-on-apple-silicon-macs/