Skip to main content
Question

Help with 1 button reinstall script


Forum|alt.badge.img+5

My script looks like this:

 

#!/bin/sh TITLE="Delete EVERYTHING and reinstall macOS" HEADLINE="WARNING!! This will erase EVERYTHING!" DECSCRIPTION1="This will erase ALL content and reinstall this mac." DECSCRIPTION2="This will erase ALL content and reinstall this mac. Are you sure you want to continue?" DECSCRIPTION3="Make sure to connect a power supply!" LOG="/private/tmp/install_mac_os.log" echo "Erase and reinstall macOS" > $LOG power=$(pmset -g batt | head -n 1 | cut -d \\' -f2) echo "Power source: $power" > $LOG HELPER=$(/Library/Application\\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon /private/tmp/InstallAssistant.icns -title "$TITLE" -heading "$HEADLINE" -alignHeading center -description "$DECSCRIPTION1" -lockHUD -button1 "Cancel" -button2 "REINSTALL" -cancelButton 1 -defaultButton 1) if [[ $HELPER -eq 2 ]]; then HELPER=$(/Library/Application\\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon /private/tmp/InstallAssistant.icns -title "$TITLE" -heading "$HEADLINE" -alignHeading center -description "$DECSCRIPTION2" -lockHUD -button1 "Cancel" -button2 "YES, DO IT" -cancelButton 1 -defaultButton 1) if [[ $HELPER -eq 2 ]]; then if [[ "$power" != "AC Power" ]]; then HELPER=$(/Library/Application\\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon /private/tmp/InstallAssistant.icns -title "$TITLE" -heading "$HEADLINE" -alignHeading center -description "$DECSCRIPTION3" -lockHUD -button1 "Ok" -cancelButton 1 -defaultButton 1) fi echo "Ok, we reinstall" >> $LOG else echo "Abort" exit 0 fi else echo "Abort" exit 0 fi open $LOG echo "Setting: do not sleep for 3600 seconds (1 hour)" >> $LOG # Do not sleep for 3600 seconds (1 hour) caffeinate -u -d -t 3600 & echo "Downloading installer..." >> $LOG # Download installer softwareupdate --fetch-full-installer >> $LOG echo "Preparing wipe and reinstall..." >> $LOG # Wipe and reinstall /Applications/Install\\ macOS Monterey.app/Contents/Resources/startosinstall --eraseinstall --agreetolicense --newvolumename 'Macintosh HD' >> $LOG

It works just fine all the way up to the startosinstall command.

Instead of starting the installer command, it open the macOS Monterey installer

As if I rand only the app: /Applications/Install\\ macOS Monterey.app

8 replies

Forum|alt.badge.img+2
  • New Contributor
  • 10 replies
  • November 17, 2021

Are you testing on Intel or M1? If M1, you have to pass credentials to startosinstall. Similar to here: https://community.jamf.com/t5/jamf-pro/macos-installer-script-not-working-for-apple-silicon-m1-macbook/m-p/250876


Forum|alt.badge.img+7
  • Contributor
  • 37 replies
  • November 17, 2021

echo $pass | /Applications/Install macOS Big Sur.app/Contents/Resources/startosinstall --eraseinstall --newvolumename "Macintosh HD" --nointeraction --agreetolicense --forcequitapps --user $user --stdinpass


Forum|alt.badge.img+5
  • Author
  • Contributor
  • 35 replies
  • November 17, 2021
jbembry wrote:

Are you testing on Intel or M1? If M1, you have to pass credentials to startosinstall. Similar to here: https://community.jamf.com/t5/jamf-pro/macos-installer-script-not-working-for-apple-silicon-m1-macbook/m-p/250876


I'm on intel (though we have a few M1's as well)

Which password should I pass? The mgmt user's?


Forum|alt.badge.img+7
  • Contributor
  • 37 replies
  • November 17, 2021

the command is for both chips (intel and M1)
the credentials are of the user who has the Secure Token

https://support.apple.com/de-de/guide/deployment/dep24dbdcf9e/web


Forum|alt.badge.img+5
  • Author
  • Contributor
  • 35 replies
  • November 17, 2021
ivanlovisi wrote:

the command is for both chips (intel and M1)
the credentials are of the user who has the Secure Token

https://support.apple.com/de-de/guide/deployment/dep24dbdcf9e/web


Yes, well I obviously doesn't have it as I'm running as a script 🙁


Forum|alt.badge.img+7
  • Contributor
  • 37 replies
  • November 17, 2021
michael_madsen wrote:

Yes, well I obviously doesn't have it as I'm running as a script 🙁


dummy question, but you don't have an error on the path? 
/Applications/Install\\ macOS Monterey.app 
but 
/Applications/Install\\ macOS\\ Monterey.app


Forum|alt.badge.img+5
  • Author
  • Contributor
  • 35 replies
  • November 17, 2021
ivanlovisi wrote:

dummy question, but you don't have an error on the path? 
/Applications/Install\\ macOS Monterey.app 
but 
/Applications/Install\\ macOS\\ Monterey.app


Yes, you are right. Well spotted 🙂


Forum|alt.badge.img+5
  • Author
  • Contributor
  • 35 replies
  • November 17, 2021

I have now included the user and password, but it still doesn't start. It opens the installer as an application

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings