39 lines
1.8 KiB
Bash
Executable File
39 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
##########################################################################
|
|
# Shellscript : Reinstall macOS
|
|
# Autor : Andreas Vogel, NEXT Enterprise gmbh, 2021
|
|
##########################################################################
|
|
set -x
|
|
##################### Variables ##########################################
|
|
Installer=$(find /Applications -type d -name 'Install macOS*')
|
|
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
|
|
jamf="/usr/local/bin/jamf"
|
|
Icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
|
|
|
|
Message="When continuing, the entire system will be deleted and with it all stored data on the device.
|
|
The device can then be rolled back into the management system.
|
|
If data is not yet saved, please cancel the process and save the data.
|
|
If you click OK, the process can no longer be canceled.
|
|
Follow the instructions from the confluence for re-installation.
|
|
"
|
|
|
|
#################### Execution ##########################################
|
|
HELPER=$("$jamfHelper" -windowType utility -icon "$Icon" -title "Clean reinstallation macOS" -description "$Message" -button1 "OK" -button2 "Cancel" -cancelButton "2" -defaultButton 2)
|
|
echo "Jamf Helper Exit Code: $HELPER"
|
|
|
|
if [ "$HELPER" == "0" ]
|
|
then
|
|
if [ -d "$Installer" ]
|
|
then
|
|
rm -rf "$Installer"
|
|
softwareupdate --fetch-full-installer
|
|
Installer=$(find /Applications -type d -name 'Install macOS*')
|
|
"$Installer"/Contents/Resources/startosinstall --eraseinstall --newvolumename "Macintosh HD" --agreetolicense
|
|
else
|
|
softwareupdate --fetch-full-installer
|
|
Installer=$(find /Applications -type d -name 'Install macOS*')
|
|
"$Installer"/Contents/Resources/startosinstall --eraseinstall --newvolumename "Macintosh HD" --agreetolicense
|
|
fi
|
|
else
|
|
exit 0
|
|
fi |