#!/bin/bash ########################################################################## # Shellscript : Check Xcode # Autor : Michelle Tembaak, macenterprise gmbh, 14.01.2020 ########################################################################## # Das Script prueft, ob eine veraltete Version von Xcode installiert ist und fuehrt die Installation von macOS 10.15 durch ##### Variabeln #### jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" WarningIcon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns" installIcon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertCautionIcon.icns" catIcon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarAdvanced.icns" Message2="Moechtest du die Installation von macOS 10.15 jetzt durchfuehren?" Message="Auf deinem Rechner befindet sich eine alte Version von Xcode. Bitte beachte, dass die Command Line Tools fuer Xcode 10.x unter macOS 10.15 nicht mehr unterstuetzt werden. Moechtest du mit der Installation von macOS 10.15 fortfahren?" installationMessage="Die Installation von macOS 10.15. wird gestartet" cancleMessage="Die Installation wurde abgebrochen." Title="Installation macOS 10.15" liste=$(ls -ls /Applications/ | grep 'Xcode' | awk '{print $10}' ) #### Funktionen #### Button() { jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" "$jamfHelper" -windowType utility -icon "$1" -title "$2" -description "$3" -button1 "Ja" -button2 "Nein" -cancelButton "2" -defaultButton 2 return } Abbruch() { jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" "$jamfHelper" -windowType utility -icon "$1" -title "$2" -description "$3" -button1 "OK" -defaultButton 1 } Installation() { jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" "$jamfHelper" -windowType utility -icon "$1" -title "$2" -description "$3" -button1 "OK" -defaultButton 1 } HELPER() { jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" "$jamfHelper" -windowType utility -icon "$1" -title "$2" -description "$3" -button1 "Ja" -button2 "Nein" -cancelButton "2" -defaultButton 2 return } #entpackeInstaller() #{ # installer -pkg /Library/Application\ Support/JAMF/Waiting\ Room/Install\ macOS\ Catalina.pkg -target / #} startInstall() { /Applications/Install\ macOS\ Catalina.app/Contents/Resources/startosinstall --agreetolicense --nointeraction } #### Ausführung ### #Abfrage, ob der User die Installation von macOS10.15 jetzt durchfuehren moechte button=$(Button "$catIcon" "$Title" "$Message2") echo "Exit Code: $button" if [[ $button -ne 0 ]]; then echo "Installation wurde abgebrochen" Abbruch "$installIcon" "$Title" "$cancleMessage" exit 0 fi #Prueft ob Xcode installiert ist. #Ist keine Version von Xcode installiert, wird die macOS Installation durchgefuehrt. if [ -z "$liste" ] then echo "Kein Xcode installiert" Installation "$installIcon" "$Title" "$installationMessage" entpackeInstaller startInstall exit 0 else echo "Xcode ist installiert." fi #Ermittelt die Version und prueft ob eine Version aelter als Xcode 11 installiert ist for i in $liste do version="$(defaults read /Applications/$i/Contents/version.plist CFBundleShortVersionString | cut -d . -f 1 )" if [[ $version -lt 11 ]]; then alteVersion="Ja" break fi done #Erfragt, ob die Installation trotz alter Xcode-Version, durchgefuehrt werden soll bzw. fuehrt die installation von 10.15 automatisch durch, wenn keine alte Xcode-Version vorhanden ist. if [[ $alteVersion == "Ja" ]]; then echo "Du hast eine alte Version installiert. Moechtest du fortfahren?" helper=$(HELPER "$WarningIcon" "$Title" "$Message") echo "Exit Code: $helper" if [[ $helper -eq 0 ]]; then echo "Starte Installation" Installation "$installIcon" "$Title" "$installationMessage" #entpackeInstaller startInstall else echo "Abbruch" Abbruch "$installIcon" "$Title" "$cancleMessage" fi else echo "Installation wird ausgefuehrt" Installation "$installIcon" "$Title" "$installationMessage" #entpackeInstaller startInstall fi exit 0