#!/bin/bash # shellcheck disable=SC2001 # this is to use sed in the case statements # shellcheck disable=SC2034 # this is due to the dynamic variable assignments used in the localization strings ############### ## VARIABLES ## ############### # script name script_name="erase-install" # Version of this script version="25.0" # URL for downloading installinstallmacos.py installinstallmacos_url="https://raw.githubusercontent.com/grahampugh/macadmin-scripts/main/installinstallmacos.py" installinstallmacos_checksum="08ceb0187bd648e040c8ba23f79192f7d91b1250dbff47107c29cb2bca1ce433" # Directory in which to place the macOS installer. Overridden with --path installer_directory="/Applications" # Default working directory (may be overridden by the --workdir parameter) workdir="/Library/Management/erase-install" # URL for downloading macadmins python (with tag version) for standalone script running macadmins_python_version="v.3.9.5.09222021234106" macadmins_python_url="https://api.github.com/repos/macadmins/python/releases/tags/$macadmins_python_version" macadmins_python_path="/Library/ManagedFrameworks/Python/Python3.framework/Versions/Current/bin/python3" # Dialog helper apps jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" depnotify_app="/Applications/Utilities/DEPNotify.app" depnotify_log="/var/tmp/depnotify.log" depnotify_confirmation_file="/var/tmp/com.depnotify.provisioning.done" depnotify_download_url="https://files.nomad.menu/DEPNotify.pkg" ################### ## LOCALIZATIONS ## ################### # Grab currently logged in user to set the language for Dialogue messages current_user=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | /usr/bin/awk -F': ' '/[[:space:]]+Name[[:space:]]:/ { if ( $2 != "loginwindow" ) { print $2 }}') language=$(/usr/libexec/PlistBuddy -c 'print AppleLanguages:0' "/Users/${current_user}/Library/Preferences/.GlobalPreferences.plist") if [[ $language = de* ]]; then user_language="de" elif [[ $language = nl* ]]; then user_language="nl" elif [[ $language = fr* ]]; then user_language="fr" else user_language="en" fi # Dialogue localizations - download window dialog_dl_title_en="Downloading macOS" dialog_dl_title_de="macOS wird heruntergeladen" dialog_dl_title_nl="macOS downloaden" dialog_dl_title_fr="Téléchargement de macOS" dialog_dl_desc_en="We need to download the macOS installer to your computer; this will take several minutes." dialog_dl_desc_de="Der macOS Installer wird heruntergeladen, dies dauert mehrere Minuten." dialog_dl_desc_nl="We moeten het macOS besturingssysteem downloaden, dit duurt enkele minuten." dialog_dl_desc_fr="Nous devons télécharger le programme d'installation de macOS sur votre ordinateur, cela prendra plusieurs minutes." # Dialogue localizations - erase lockscreen dialog_erase_title_en="Erasing macOS" dialog_erase_title_de="macOS wiederherstellen" dialog_erase_title_nl="macOS herinstalleren" dialog_erase_title_fr="Effacement de macOS" dialog_erase_desc_en="Preparing the installer may take up to 30 minutes. Once completed your computer will reboot and continue the reinstallation." dialog_erase_desc_de="Das Vorbereiten des Installationsprogramms kann bis zu 30 Minuten dauern. Nach Abschluss wird Ihr Computer neu gestartet und die Neuinstallation fortgesetzt." dialog_erase_desc_nl="Het voorbereiden van het installatieprogramma kan tot 30 minuten duren. Zodra het proces is voltooid, wordt uw computer opnieuw opgestart en wordt de herinstallatie voortgezet." dialog_erase_desc_fr="La préparation de l'installation peut prendre jusqu'à 30 minutes. Une fois terminée, votre ordinateur redémarrera et poursuivra la réinstallation." # Dialogue localizations - reinstall lockscreen dialog_reinstall_title_en="Upgrading macOS" dialog_reinstall_title_de="Upgrading macOS" dialog_reinstall_title_nl="macOS upgraden" dialog_reinstall_title_fr="Mise à niveau de macOS" dialog_reinstall_status_en="Preparing macOS for installation" dialog_reinstall_status_de="Vorbereiten von macOS für die Installation" dialog_reinstall_status_nl="MacOS voorbereiden voor installatie" dialog_reinstall_status_fr="Préparation de macOS pour l'installation" dialog_reinstall_heading_en="Please wait as we prepare your computer for upgrading macOS." dialog_reinstall_heading_de="Bitte warten, das Upgrade macOS wird ausgeführt." dialog_reinstall_heading_nl="Even geduld terwijl we uw computer voorbereiden voor de upgrade van macOS." dialog_reinstall_heading_fr="Veuillez patienter pendant que nous préparons votre ordinateur pour la mise à niveau de macOS." dialog_reinstall_desc_en="This process may take up to 30 minutes. Once completed your computer will reboot and begin the upgrade." dialog_reinstall_desc_de="Dieser Prozess benötigt bis zu 30 Minuten. Der Mac startet anschliessend neu und beginnt mit dem Update." dialog_reinstall_desc_nl="Dit proces duurt ongeveer 30 minuten. Zodra dit is voltooid, wordt uw computer opnieuw opgestart en begint de upgrade." dialog_reinstall_desc_fr="Ce processus peut prendre jusqu'à 30 minutes. Une fois terminé, votre ordinateur redémarrera et commencera la mise à niveau." # Dialogue localizations - confirmation window (erase) dialog_erase_confirmation_desc_en="Please confirm that you want to ERASE ALL DATA FROM THIS DEVICE and reinstall macOS" dialog_erase_confirmation_desc_de="Bitte bestätigen, dass Sie ALLE DATEN VON DIESEM GERÄT LÖSCHEN und macOS neu installieren wollen" dialog_erase_confirmation_desc_nl="Weet je zeker dat je ALLE GEGEVENS VAN DIT APPARAAT WILT WISSEN en macOS opnieuw installeert?" dialog_erase_confirmation_desc_fr="Veuillez confirmer que vous souhaitez EFFACER TOUTES LES DONNÉES DE CET APPAREIL et réinstaller macOS" # Dialogue localizations - confirmation window (reinstall) dialog_reinstall_confirmation_desc_en="Please confirm that you want to upgrade macOS on this system now" dialog_reinstall_confirmation_desc_de="Bitte bestätigen Sie, dass Sie macOS auf diesem System jetzt aktualisieren möchten" dialog_reinstall_confirmation_desc_nl="Bevestig dat u macOS op dit systeem nu wilt updaten" dialog_reinstall_confirmation_desc_fr="Veuillez confirmer que vous voulez mettre à jour macOS sur ce système maintenant." # Dialogue localizations - confirmation window status dialog_confirmation_status_en="Press Cmd + Ctrl + C to Cancel" dialog_confirmation_status_de="Drücken Sie Cmd + Ctrl + C zum Abbrechen" dialog_confirmation_status_nl="Druk op Cmd + Ctrl + C om te Annuleren" dialog_confirmation_status_fr="Appuyez sur Cmd + Ctrl + C pour annuler" # Dialogue buttons dialog_confirmation_button_en="Confirm" dialog_confirmation_button_de="Bestätigen" dialog_confirmation_button_nl="Bevestig" dialog_confirmation_button_fr="Confirmer" dialog_cancel_button_en="Stop" dialog_cancel_button_de="Abbrechen" dialog_cancel_button_nl="Annuleren" dialog_cancel_button_fr="Annuler" dialog_enter_button_en="Enter" dialog_enter_button_de="Eingeben" dialog_enter_button_nl="Enter" dialog_enter_button_fr="Entrer" # Dialogue localizations - free space check dialog_check_desc_en="The macOS upgrade cannot be installed as there is not enough space left on the drive." dialog_check_desc_de="Das Upgrade von macOS kann nicht installiert werden, da nicht genügend Speicherplatz auf dem Laufwerk vorhanden ist." dialog_check_desc_nl="De upgrade van macOS kan niet worden geïnstalleerd omdat er niet genoeg ruimte is op de schijf." dialog_check_desc_fr="La mise à niveau de macOS ne peut pas être installée car il n'y a pas assez d'espace disponible sur ce volume." # Dialogue localizations - power check dialog_power_title_en="Waiting for AC Power Connection" dialog_power_title_de="Warten auf AC-Netzteil" dialog_power_title_nl="Wachten op stroomadapter" dialog_power_title_fr="En attente de l'alimentation secteur" dialog_power_desc_en="Please connect your computer to power using an AC power adapter. This process will continue if AC power is detected within the next:" dialog_power_desc_de="Bitte schließen Sie Ihren Computer mit einem AC-Netzteil an das Stromnetz an. Dieser Prozess wird fortgesetzt, sobald die AC-Stromversorgung innerhalb der folgende Zeitdauer erkannt wird:" dialog_power_desc_nl="Sluit uw computer aan met de stroomadapter. Zodra deze is gedetecteerd gaat het proces verder binnen de volgende:" dialog_power_desc_fr="Veuillez connecter votre ordinateur à un adaptateur secteur. Ce processus se poursuivra une fois que l'alimentation secteur sera détectée dans la suivante:" dialog_nopower_desc_en="Exiting. AC power was not connected after waiting for:" dialog_nopower_desc_de="Beenden. Die Stromversorgung wurde nach einer Wartezeit nicht hergestellt:" dialog_nopower_desc_nl="Afsluiten. De wisselstroom was niet aangesloten na het wachten op:" dialog_nopower_desc_fr="Sortie. Le courant alternatif n'a pas été connecté après avoir attendu:" # Dialogue localizations - ask for short name dialog_short_name_en="Please enter an account name to start the reinstallation process" dialog_short_name_de="Bitte geben Sie einen Kontonamen ein, um die Neuinstallation zu starten" dialog_short_name_nl="Voer een accountnaam in om het installatieproces te starten" dialog_short_name_fr="Veuillez entrer un nom de compte pour démarrer le processus de réinstallation" # Dialogue localizations - ask for password dialog_not_volume_owner_en="Account is not a Volume Owner! Please login using one of the following accounts and try again" dialog_not_volume_owner_de="Konto ist kein Volume-Besitzer! Bitte melden Sie sich mit einem der folgenden Konten an und versuchen Sie es erneut" dialog_not_volume_owner_nl="Account is geen volume-eigenaar! Log in met een van de volgende accounts en probeer het opnieuw" dialog_not_volume_owner_fr="Le compte n'est pas propriétaire du volume! Veuillez vous connecter en utilisant l'un des comptes suivants et réessayer" # Dialogue localizations - invalid user dialog_user_invalid_en="This account cannot be used to to perform the reinstall" dialog_user_invalid_de="Dieses Konto kann nicht zur Durchführung der Neuinstallation verwendet werden" dialog_user_invalid_nl="Dit account kan niet worden gebruikt om de herinstallatie uit te voeren" dialog_user_invalid_fr="Ce compte ne peut pas être utilisé pour effectuer la réinstallation" # Dialogue localizations - invalid password dialog_invalid_password_en="ERROR: The password entered is NOT the login password for" dialog_invalid_password_de="ERROR: Das eingegebene Kennwort ist NICHT das Anmeldekennwort für" dialog_invalid_password_nl="FOUT: Het ingevoerde wachtwoord is NIET het inlogwachtwoord voor" dialog_invalid_password_fr="ERREUR : Le mot de passe entré n'est PAS le mot de passe de connexion pour" # Dialogue localizations - not a volume owner dialog_get_password_en="Please enter the password for the account" dialog_get_password_de="Bitte geben Sie das Passwort für das Konto ein" dialog_get_password_nl="Voer het wachtwoord voor het account in" dialog_get_password_fr="Veuillez saisir le mot de passe du compte" # icon for download window dialog_dl_icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/SidebarDownloadsFolder.icns" # icon for confirmation dialog dialog_confirmation_icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns" # set localisation variables dialog_dl_title=dialog_dl_title_${user_language} dialog_dl_desc=dialog_dl_desc_${user_language} dialog_erase_title=dialog_erase_title_${user_language} dialog_erase_desc=dialog_erase_desc_${user_language} dialog_reinstall_title=dialog_reinstall_title_${user_language} dialog_reinstall_heading=dialog_reinstall_heading_${user_language} dialog_reinstall_desc=dialog_reinstall_desc_${user_language} dialog_reinstall_status=dialog_reinstall_status_${user_language} dialog_erase_confirmation_title=dialog_erase_confirmation_title_${user_language} dialog_erase_confirmation_desc=dialog_erase_confirmation_desc_${user_language} dialog_confirmation_status=dialog_confirmation_status_${user_language} dialog_confirmation_button=dialog_confirmation_button_${user_language} dialog_reinstall_confirmation_title=dialog_reinstall_confirmation_title_${user_language} dialog_reinstall_confirmation_desc=dialog_reinstall_confirmation_desc_${user_language} dialog_cancel_button=dialog_cancel_button_${user_language} dialog_enter_button=dialog_enter_button_${user_language} dialog_check_desc=dialog_check_desc_${user_language} dialog_power_desc=dialog_power_desc_${user_language} dialog_nopower_desc=dialog_nopower_desc_${user_language} dialog_power_title=dialog_power_title_${user_language} dialog_short_name=dialog_short_name_${user_language} dialog_user_invalid=dialog_user_invalid_${user_language} dialog_get_password=dialog_get_password_${user_language} dialog_invalid_password=dialog_invalid_password_${user_language} dialog_not_volume_owner=dialog_not_volume_owner_${user_language} ############### ## FUNCTIONS ## ############### ask_for_password() { # required for Silicon Macs /usr/bin/osascript <