kc9wwh / macOSUpgrade

Workflow for doing in-place upgrades.
Other
418 stars 103 forks source link

Feature Request: User text input confirmation for Erase option #108

Closed redshirtdave closed 5 years ago

redshirtdave commented 5 years ago

I have implemented a confirmation option which forces the user to type 'ERASE' before the policy will execute. Others might find this useful too, I placed it at the top of the script. Improvements welcome. This does not factor in the $8 variable.

userConfirmation=$(osascript << EOF
text returned of (display dialog "Confirm that you want to reset your Mac and lose all data by typing ERASE" with title "Erase Mac and Install macOS Mojave" default answer "" buttons {"Exit","Continue"} default button 1)
EOF)

if [[ $userConfirmation == ERASE ]]
    then
        echo user confirmed intent to reset macOS and erase all data by typing ERASE
    else
        echo user cancelled macOS reset
        osascript -e 'display dialog "Cancelled." with title "Erase Mac and Install macOS Mojave" buttons {"OK"} default button 1'
        exit 0
fi
kenchan0130 commented 5 years ago

@redshirtdave Thank you for your proposal.

Of course, we think this script needs to be simple for admins and end users. We have no plans to enrich the script of this project beyond its update functionality.

Your suggested patch might be complicate for this project. However, please do not give up. If you want end users to choose erase, currently we have two options.

Option 1. Create two policies. One is setting $8 variable to 0 as macOSUpgrade without Erasing Installer Policy, the other is setting $8 variable to 1 as macOSUpgrade with Erasing Installer Policy. Option 2. Create three policies. One is setting $8 variable to 0 with macOSUpgrade-without-erasing-installer event as macOSUpgrade without Erasing Installer Policy. Two is setting $8 variable to 1 with macOSUpgrade-with-erasing-installer event as macOSUpgrade with Erasing Installer Policy, the other is setting your custom dialog script like

#!/bin/bash
userConfirmation=$(osascript << EOF
text returned of (display dialog "Confirm that you want to reset your Mac and lose all data by typing ERASE" with title "Erase Mac and Install macOS Mojave" default answer "" buttons {"Exit","Continue"} default button 1)
EOF)

if [ "$userConfirmation" = "ERASE" ];then
  jamf policy -event "macOSUpgrade-with-erasing-installer"
else
  jamf policy -event "macOSUpgrade-without-erasing-installer"
fi

exit 0

as macOSUpgrade with option for end user.

kenchan0130 commented 5 years ago

@redshirtdave

How did it go after that? If you have any problems, please let us know.

kenchan0130 commented 5 years ago

If you still have problems, please reopen.