#!/bin/bash ######################################################################################### # Shellscript : DEP Notify Skript # Autor : Andreas Vogel, nextenterprise gmbh # Quelle : https://github.com/jamf/DEPNotify-Starter/blob/master/README.md ######################################################################################### ######################################################################################### # Testing Mode ######################################################################################### TESTING_MODE=false FULLSCREEN=true ######################################################################################### # General Appearance # Normale Variablen ######################################################################################### BANNER_IMAGE_PATH="/Applications/Self Service.app/Contents/Resources/AppIcon.icns" ORG_NAME="Exasol AG" BANNER_TITLE="Welcome to the $ORG_NAME" SUPPORT_CONTACT_DETAILS="ServiceDesk@exasol.com" MAIN_TEXT='On the Mac, some applications and settings are configured before you start using your new Mac. This process can take 5 to 10 minutes. \n \n If you need additional software or help, visit the Self-Service app in your Applications folder or Dock. \n \n Office applications ( Word, Excel, Outlook and Powerpoint) are available in Self Service.' INITAL_START_STATUS="Start initial configuration..." INSTALL_COMPLETE_TEXT="Configuration completed!" COMPLETE_METHOD_DROPDOWN_ALERT=false ######################################################################################### COMPLETE_ALERT_TEXT="Your Mac is now done with the initial setup and configuration. Press Exit to get started!" COMPLETE_MAIN_TEXT='Your Mac is now done with the initial setup and configuration.' COMPLETE_BUTTON_TEXT="Finished!" ######################################################################################### # Plist Configuration ######################################################################################### INFO_PLIST_WRAPPER (){ DEP_NOTIFY_USER_INPUT_PLIST="/Users/$CURRENT_USER/Library/Preferences/menu.nomad.DEPNotifyUserInput.plist" } STATUS_TEXT_ALIGN="center" # Status Textausrichtung. Der Statustext unter dem Fortschrittsbalken kann so konfiguriert werden, dass er links, rechts oder mittig ist HELP_BUBBLE_TITLE="Do you need help?" # Konfiguration der Hilfetaste HELP_BUBBLE_BODY="This tool was developed by IT to facilitate the onboarding of new employees. \n If you have any problems, please contact $SUPPORT_CONTACT_DETAILS" ######################################################################################### # Error Screen Text ######################################################################################### # Wenn der Testmodus falsch ist und Konfigurationsdateien vorhanden sind, wird dieser Text angezeigt # den Endbenutzer und bitten Sie ihn, sich an die IT zu wenden. Eingeschränkte Fensteroptionen hier als # Annahme ist, dass sie IT anrufen müssen. Es werden keine Fortsetzungs- oder Beendigungsschaltflächen für angezeigt # DEP Benachrichtigungsfenster und es wird nicht im Vollbildmodus angezeigt. IT-Mitarbeiter müssen Terminal verwenden # oder Aktivitätsmonitor zum Beenden von DEP Notify. ERROR_BANNER_TITLE="Oh there is something wrong!" # Hauptüberschrift, die unter dem Bild angezeigt wird ERROR_MAIN_TEXT='We are sorry that you are having this inconvenience with your new Mac. \n \n ou should contact IT immediately. We will look at your computer as soon as possible. \n \n' ERROR_MAIN_TEXT="$ERROR_MAIN_TEXT $SUPPORT_CONTACT_DETAILS" ERROR_STATUS="Setup failed" ######################################################################################### # Policy Variable to Modify # Welche Policies sollen hier ausgefüht werden. # Die Policies werden dann in dieser Folge abgearbeitet. ######################################################################################### POLICY_ARRAY=( "Gerätename wird gesetzt,tests" ) ######################################################################################### # Caffeinate / No Sleep Configuration ######################################################################################### # NO_SLEEP=false # Flag-Skript, um den Computer vom Schlafen abzuhalten ######################################################################################### # Customized Self Service Branding ######################################################################################### SELF_SERVICE_CUSTOM_BRANDING=true # Set variable to true or false SELF_SERVICE_APP_NAME="Self Service.app" # Wenn Sie einen anderen Namen als Self Service mit benutzerdefiniertem Branding verwenden SELF_SERVICE_CUSTOM_WAIT=20 # Anzahl der Sekunden, die auf das benutzerdefinierte Self-Service-Symbol gewartet werden soll (Sekunden) ######################################################################################### # EULA Variables to Modify # ######################################################################################### EULA_ENABLED=false # Set variable to true or false. EULA configuration EULA_STATUS="Waiting for EULA acceptance to be completed" # EULA status bar text EULA_BUTTON="Read and agree to the EULA" # EULA button text on the main screen EULA_MAIN_TITLE="Organization End User License Agreement" # EULA Screen Title EULA_SUBTITLE="Please agree to the following conditions to start the configuration of this Mac" # EULA Subtitle EULA_FILE_PATH="/Users/Shared/eula.txt" # Path to the EULA file. ######################################################################################### # Registration Variables to Modify # ######################################################################################### REGISTRATION_ENABLED=false # Set variable to true or false. Registration window configuration REGISTRATION_TITLE="Register the Mac under $ORG_NAME" # Registration window title REGISTRATION_STATUS="Waiting after the computer registration is completed" # Registration status bar text REGISTRATION_BUTTON="Register your Mac" # Registration window submit or finish button text REGISTRATION_BEGIN_WORD="Setting" # The text and pick list sections below will write the following lines out for end users REGISTRATION_MIDDLE_WORD="to" ######################################################################################### # First Text Field # Kann alles mögliche dann abfragen. # Die abarbeitung wird dann in der Funktion "REG_TEXT_LABEL_1_LOGIC" ausgeführt. In diesem # Fall wird das Asset Tag abgefragt und über den recon aktuallisiert. ######################################################################################### REG_TEXT_LABEL_1="Asset Tag" # Text Field Label REG_TEXT_LABEL_1_PLACEHOLDER="81926392" # Place Holder Text REG_TEXT_LABEL_1_OPTIONAL="false" # Optional flag for making the field an optional input for end user REG_TEXT_LABEL_1_HELP_TITLE="Asset Tag" # Help Bubble for Input. If title left blank, this will not appear REG_TEXT_LABEL_1_HELP_TEXT="This field is used to assign an updated asset tag to our asset management system. The asset tag can be found on the bottom of the device." REG_TEXT_LABEL_1_LOGIC (){ REG_TEXT_LABEL_1_VALUE=$(/usr/bin/defaults read "$DEP_NOTIFY_USER_INPUT_PLIST" "$REG_TEXT_LABEL_1") if [ "$REG_TEXT_LABEL_1_OPTIONAL" = true ] && [ "$REG_TEXT_LABEL_1_VALUE" = "" ]; then echo "Status: $REG_TEXT_LABEL_1 was left blank. Skip..." >> "$DEP_NOTIFY_LOG" echo "$(date "+%a %h %d %H:%M:%S"): $REG_TEXT_LABEL_1 wurde auf optional gesetzt und leer gelassen. Überspringen..." >> "$DEP_NOTIFY_DEBUG" sleep 5 else echo "Status: $REGISTRATION_BEGIN_WORD $REG_TEXT_LABEL_1 $REGISTRATION_MIDDLE_WORD $REG_TEXT_LABEL_1_VALUE" >> "$DEP_NOTIFY_LOG" if [ "$TESTING_MODE" = true ]; then sleep 10 else "$JAMF_BINARY" recon -assetTag "$REG_TEXT_LABEL_1_VALUE" fi fi } ######################################################################################### ######################################################################################### # Core Script Logic - Don't Change Without Major Testing ######################################################################################### ######################################################################################### # Variables for File Paths ######################################################################################### JAMF_BINARY="/usr/local/bin/jamf" FDE_SETUP_BINARY="/usr/bin/fdesetup" DEP_NOTIFY_APP="/Applications/Utilities/DEPNotify.app" DEP_NOTIFY_LOG="/var/tmp/depnotify.log" DEP_NOTIFY_DEBUG="/var/tmp/depnotifyDebug.log" DEP_NOTIFY_DONE="/var/tmp/com.depnotify.provisioning.done" ######################################################################################### # Variablen die aus Jamf übergeben werden können. # !! Wichtig !! egal was oben in den Variablen angegeben ist, wird hierdurch überschrieben. ######################################################################################### if [ "$4" != "" ]; then TESTING_MODE="$4"; fi if [ "$5" != "" ]; then FULLSCREEN="$5"; fi #if [ "$6" != "" ]; then NO_SLEEP="$6"; fi if [ "$7" != "" ]; then SELF_SERVICE_CUSTOM_BRANDING="$7"; fi if [ "$8" != "" ]; then COMPLETE_METHOD_DROPDOWN_ALERT="$8"; fi if [ "$9" != "" ]; then EULA_ENABLED="$9"; fi if [ "${10}" != "" ]; then REGISTRATION_ENABLED="${10}"; fi ######################################################################################### # Standard Testing Mode Enhancements # Nur wenn der Testing Mode "true" ist. Die angelegten Logs werden gelöscht, damit keine # Error Meldung erfolgt. ######################################################################################### if [ "$TESTING_MODE" = true ]; then if [ -f "$DEP_NOTIFY_LOG" ]; then rm "$DEP_NOTIFY_LOG"; fi if [ -f "$DEP_NOTIFY_DONE" ]; then rm "$DEP_NOTIFY_DONE"; fi if [ -f "$DEP_NOTIFY_DEBUG" ]; then rm "$DEP_NOTIFY_DEBUG"; fi # Setting Quit Key set to command + control + x (Testing Mode Only) echo "Command: QuitKey: x" >> "$DEP_NOTIFY_LOG" fi ######################################################################################### # Püfung der Variablen auf true/false ######################################################################################### if [ "$TESTING_MODE" != true ] && [ "$TESTING_MODE" != false ]; then echo "$(date "+%a %h %d %H:%M:%S"): Testkonfiguration nicht richtig eingestellt. Derzeit eingestellt auf $TESTING_MODE. Bitte aktualisieren Sie auf true oder false." >> "$DEP_NOTIFY_DEBUG" exit 1 fi if [ "$FULLSCREEN" != true ] && [ "$FULLSCREEN" != false ]; then echo "$(date "+%a %h %d %H:%M:%S"): Die Vollbildkonfiguration ist nicht richtig eingestellt. Derzeit eingestellt auf $FULLSCREEN. Bitte aktualisieren Sie auf true oder false." >> "$DEP_NOTIFY_DEBUG" exit 1 fi # if [ "$NO_SLEEP" != true ] && [ "$NO_SLEEP" != false ]; then # echo "$(date "+%a %h %d %H:%M:%S"): Schlafkonfiguration nicht richtig eingestellt. Derzeit eingestellt auf $NO_SLEEP. Bitte aktualisieren Sie auf true oder false." >> "$DEP_NOTIFY_DEBUG" # exit 1 # fi if [ "$SELF_SERVICE_CUSTOM_BRANDING" != true ] && [ "$SELF_SERVICE_CUSTOM_BRANDING" != false ]; then echo "$(date "+%a %h %d %H:%M:%S"): Self Service Custom Branding-Konfiguration nicht richtig eingestellt. Derzeit eingestellt auf $SELF_SERVICE_CUSTOM_BRANDING. Bitte aktualisieren Sie auf true oder false." >> "$DEP_NOTIFY_DEBUG" exit 1 fi if [ "$COMPLETE_METHOD_DROPDOWN_ALERT" != true ] && [ "$COMPLETE_METHOD_DROPDOWN_ALERT" != false ]; then echo "$(date "+%a %h %d %H:%M:%S"): Abschlusswarnmethode nicht richtig eingestellt. Derzeit eingestellt auf $COMPLETE_METHOD_DROPDOWN_ALERT. Bitte aktualisieren Sie auf true oder false." >> "$DEP_NOTIFY_DEBUG" exit 1 fi if [ "$EULA_ENABLED" != true ] && [ "$EULA_ENABLED" != false ]; then echo "$(date "+%a %h %d %H:%M:%S"): EULA-Konfiguration nicht richtig eingestellt. Derzeit eingestellt auf $EULA_ENABLED. Bitte aktualisieren Sie auf true oder false." >> "$DEP_NOTIFY_DEBUG" exit 1 fi if [ "$REGISTRATION_ENABLED" != true ] && [ "$REGISTRATION_ENABLED" != false ]; then echo "$(date "+%a %h %d %H:%M:%S"): Registrierungskonfiguration nicht richtig eingestellt. Derzeit eingestellt auf $REGISTRATION_ENABLED. Bitte aktualisieren Sie auf true oder false." >> "$DEP_NOTIFY_DEBUG" exit 1 fi ######################################################################################### # Püfung vor Ausführung auf: ############################DEP Notify ausführen nach dem Apple Setup Assistant########## SETUP_ASSISTANT_PROCESS=$(pgrep -l "Setup Assistant") until [ "$SETUP_ASSISTANT_PROCESS" = "" ]; do echo "$(date "+%a %h %d %H:%M:%S"): Setup Assistant Still Running. PID $SETUP_ASSISTANT_PROCESS." >> "$DEP_NOTIFY_DEBUG" sleep 1 SETUP_ASSISTANT_PROCESS=$(pgrep -l "Setup Assistant") done ############################Überprüfen, ob der Finder ausgeführt wird#################### FINDER_PROCESS=$(pgrep -l "Finder") until [ "$FINDER_PROCESS" != "" ]; do echo "$(date "+%a %h %d %H:%M:%S"): Finder process not found. Assuming device is at login screen." >> "$DEP_NOTIFY_DEBUG" sleep 1 FINDER_PROCESS=$(pgrep -l "Finder") done #############################Den aktuellen Benutzer zu greifen########################### CURRENT_USER=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");') echo "$(date "+%a %h %d %H:%M:%S"): Current user set to $CURRENT_USER." >> "$DEP_NOTIFY_DEBUG" ############################Kill DEPNotify, wenn bereits ausgeführt wurde################ PREVIOUS_DEP_NOTIFY_PROCESS=$(pgrep -l "DEPNotify" | cut -d " " -f1) until [ "$PREVIOUS_DEP_NOTIFY_PROCESS" = "" ]; do echo "$(date "+%a %h %d %H:%M:%S"): Stopping the previously-opened instance of DEPNotify." >> "$DEP_NOTIFY_DEBUG" kill $PREVIOUS_DEP_NOTIFY_PROCESS PREVIOUS_DEP_NOTIFY_PROCESS=$(pgrep -l "DEPNotify" | cut -d " " -f1) done ############################Stoppen Sie BigHonkingText, wenn es ausgeführt############### BIG_HONKING_TEXT_PROCESS=$(pgrep -l "BigHonkingText" | cut -d " " -f1) until [ "$BIG_HONKING_TEXT_PROCESS" = "" ]; do echo "$(date "+%a %h %d %H:%M:%S"): Stopping the previously-opened instance of BigHonkingText." >> "$DEP_NOTIFY_DEBUG" kill $BIG_HONKING_TEXT_PROCESS BIG_HONKING_TEXT_PROCESS=$(pgrep -l "BigHonkingText" | cut -d " " -f1) done ######################################################################################### # Hinzufügen von Prüfung und Warnung, wenn der Testmodus deaktiviert ist und Stücklistendateien vorhanden sind ######################################################################################### if [[ ( -f "$DEP_NOTIFY_LOG" || -f "$DEP_NOTIFY_DONE" ) && "$TESTING_MODE" = false ]]; then echo "$(date "+%a %h %d %H:%M:%S"): TESTING_MODE set to false but config files were found in /var/tmp. Letting user know and exiting." >> "$DEP_NOTIFY_DEBUG" mv "$DEP_NOTIFY_LOG" "/var/tmp/depnotify_old.log" echo "Command: MainTitle: $ERROR_BANNER_TITLE" >> "$DEP_NOTIFY_LOG" echo "Command: MainText: $ERROR_MAIN_TEXT" >> "$DEP_NOTIFY_LOG" echo "Status: $ERROR_STATUS" >> "$DEP_NOTIFY_LOG" sudo -u "$CURRENT_USER" open -a "$DEP_NOTIFY_APP" --args -path "$DEP_NOTIFY_LOG" sleep 5 echo "Command: ContinueButton: $COMPLETE_BUTTON_TEXT" >> "$DEP_NOTIFY_LOG" exit 1 fi ######################################################################################### ######################################################################################### # Wenn "SELF_SERVICE_CUSTOM_BRANDING" auf "true" gesetzt ist. Laden des aktualisierten # Brandings. Warten Sie auf das Branding-Image, um es ordnungsgemäß in der Benutzerbibliothek # anzuzeigen. Anschliessend ######################################################################################### if [ "$SELF_SERVICE_CUSTOM_BRANDING" = true ]; then open -a "/Applications/$SELF_SERVICE_APP_NAME" --hide SELF_SERVICE_COUNTER=0 CUSTOM_BRANDING_PNG="/Users/$CURRENT_USER/Library/Application Support/com.jamfsoftware.selfservice.mac/Documents/Images/brandingimage.png" until [ -f "$CUSTOM_BRANDING_PNG" ]; do echo "$(date "+%a %h %d %H:%M:%S"): Waiting for branding image from Jamf Pro." >> "$DEP_NOTIFY_DEBUG" sleep 1 (( SELF_SERVICE_COUNTER++ )) if [ $SELF_SERVICE_COUNTER -gt $SELF_SERVICE_CUSTOM_WAIT ];then CUSTOM_BRANDING_PNG="/Applications/ING Germany Self Service.app/Contents/Resources/AppIcon.icns" break fi done BANNER_IMAGE_PATH="$CUSTOM_BRANDING_PNG" SELF_SERVICE_PID=$(pgrep -l "Self Service" | cut -d' ' -f1) echo "$(date "+%a %h %d %H:%M:%S"): Self Service custom branding icon has been loaded. Killing Self Service PID $SELF_SERVICE_PID." >> "$DEP_NOTIFY_DEBUG" kill "$SELF_SERVICE_PID" fi if [ "$BANNER_IMAGE_PATH" != "" ]; then echo "Command: Image: $BANNER_IMAGE_PATH" >> "$DEP_NOTIFY_LOG"; fi # Festlegen eines benutzerdefinierten Bildes, falls angegeben if [ "$BANNER_TITLE" != "" ]; then echo "Command: MainTitle: $BANNER_TITLE" >> "$DEP_NOTIFY_LOG"; fi # Festlegen eines benutzerdefinierten Titels, falls angegeben if [ "$MAIN_TEXT" != "" ]; then echo "Command: MainText: $MAIN_TEXT" >> "$DEP_NOTIFY_LOG"; fi # Festlegen des benutzerdefinierten Haupttextes, falls angegeben # General Plist Configuration # Calling function to set the INFO_PLIST_PATH INFO_PLIST_WRAPPER # The plist information below DEP_NOTIFY_CONFIG_PLIST="/Users/$CURRENT_USER/Library/Preferences/menu.nomad.DEPNotify.plist" # If testing mode is on, this will remove some old configuration files if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_CONFIG_PLIST" ]; then rm "$DEP_NOTIFY_CONFIG_PLIST"; fi if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_USER_INPUT_PLIST" ]; then rm "$DEP_NOTIFY_USER_INPUT_PLIST"; fi # Setting default path to the plist which stores all the user completed info /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" pathToPlistFile "$DEP_NOTIFY_USER_INPUT_PLIST" # Setting status text alignment /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" statusTextAlignment "$STATUS_TEXT_ALIGN" # Setting help button if [ "$HELP_BUBBLE_TITLE" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" helpBubble -array-add "$HELP_BUBBLE_TITLE" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" helpBubble -array-add "$HELP_BUBBLE_BODY" fi # EULA Configuration if [ "$EULA_ENABLED" = true ]; then DEP_NOTIFY_EULA_DONE="/var/tmp/com.depnotify.agreement.done" # If testing mode is on, this will remove EULA specific configuration files if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_EULA_DONE" ]; then rm "$DEP_NOTIFY_EULA_DONE"; fi # Writing title, subtitle, and EULA txt location to plist /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" EULAMainTitle "$EULA_MAIN_TITLE" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" EULASubTitle "$EULA_SUBTITLE" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" pathToEULA "$EULA_FILE_PATH" # Setting ownership of EULA file chown "$CURRENT_USER:staff" "$EULA_FILE_PATH" chmod 444 "$EULA_FILE_PATH" fi # Registration Plist Configuration if [ "$REGISTRATION_ENABLED" = true ]; then DEP_NOTIFY_REGISTER_DONE="/var/tmp/com.depnotify.registration.done" # If testing mode is on, this will remove registration specific configuration files if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_REGISTER_DONE" ]; then rm "$DEP_NOTIFY_REGISTER_DONE"; fi # Main Window Text Configuration /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" registrationMainTitle "$REGISTRATION_TITLE" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" registrationButtonLabel "$REGISTRATION_BUTTON" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" registrationPicturePath "$BANNER_IMAGE_PATH" # First Text Box Configuration if [ "$REG_TEXT_LABEL_1" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField1Label "$REG_TEXT_LABEL_1" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField1Placeholder "$REG_TEXT_LABEL_1_PLACEHOLDER" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField1IsOptional "$REG_TEXT_LABEL_1_OPTIONAL" # Code for showing the help box if configured if [ "$REG_TEXT_LABEL_1_HELP_TITLE" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField1Bubble -array-add "$REG_TEXT_LABEL_1_HELP_TITLE" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField1Bubble -array-add "$REG_TEXT_LABEL_1_HELP_TEXT" fi fi # Second Text Box Configuration if [ "$REG_TEXT_LABEL_2" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField2Label "$REG_TEXT_LABEL_2" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField2Placeholder "$REG_TEXT_LABEL_2_PLACEHOLDER" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField2IsOptional "$REG_TEXT_LABEL_2_OPTIONAL" # Code for showing the help box if configured if [ "$REG_TEXT_LABEL_2_HELP_TITLE" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField2Bubble -array-add "$REG_TEXT_LABEL_2_HELP_TITLE" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField2Bubble -array-add "$REG_TEXT_LABEL_2_HELP_TEXT" fi fi # Popup 1 if [ "$REG_POPUP_LABEL_1" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton1Label "$REG_POPUP_LABEL_1" # Code for showing the help box if configured if [ "$REG_POPUP_LABEL_1_HELP_TITLE" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu1Bubble -array-add "$REG_POPUP_LABEL_1_HELP_TITLE" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu1Bubble -array-add "$REG_POPUP_LABEL_1_HELP_TEXT" fi # Code for adding the items from the array above into the plist for REG_POPUP_LABEL_1_OPTION in "${REG_POPUP_LABEL_1_OPTIONS[@]}"; do /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton1Content -array-add "$REG_POPUP_LABEL_1_OPTION" done fi # Popup 2 if [ "$REG_POPUP_LABEL_2" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton2Label "$REG_POPUP_LABEL_2" # Code for showing the help box if configured if [ "$REG_POPUP_LABEL_2_HELP_TITLE" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu2Bubble -array-add "$REG_POPUP_LABEL_2_HELP_TITLE" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu2Bubble -array-add "$REG_POPUP_LABEL_2_HELP_TEXT" fi # Code for adding the items from the array above into the plist for REG_POPUP_LABEL_2_OPTION in "${REG_POPUP_LABEL_2_OPTIONS[@]}"; do /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton2Content -array-add "$REG_POPUP_LABEL_2_OPTION" done fi # Popup 3 if [ "$REG_POPUP_LABEL_3" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton3Label "$REG_POPUP_LABEL_3" # Code for showing the help box if configured if [ "$REG_POPUP_LABEL_3_HELP_TITLE" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu3Bubble -array-add "$REG_POPUP_LABEL_3_HELP_TITLE" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu3Bubble -array-add "$REG_POPUP_LABEL_3_HELP_TEXT" fi # Code for adding the items from the array above into the plist for REG_POPUP_LABEL_3_OPTION in "${REG_POPUP_LABEL_3_OPTIONS[@]}"; do /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton3Content -array-add "$REG_POPUP_LABEL_3_OPTION" done fi # Popup 4 if [ "$REG_POPUP_LABEL_4" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton4Label "$REG_POPUP_LABEL_4" # Code for showing the help box if configured if [ "$REG_POPUP_LABEL_4_HELP_TITLE" != "" ]; then /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu4Bubble -array-add "$REG_POPUP_LABEL_4_HELP_TITLE" /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu4Bubble -array-add "$REG_POPUP_LABEL_4_HELP_TEXT" fi # Code for adding the items from the array above into the plist for REG_POPUP_LABEL_4_OPTION in "${REG_POPUP_LABEL_4_OPTIONS[@]}"; do /usr/bin/defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton4Content -array-add "$REG_POPUP_LABEL_4_OPTION" done fi fi # Changing Ownership of the plist file chown "$CURRENT_USER":staff "$DEP_NOTIFY_CONFIG_PLIST" chmod 600 "$DEP_NOTIFY_CONFIG_PLIST" # Opening the app after initial configuration if [ "$FULLSCREEN" = true ]; then sudo -u "$CURRENT_USER" open -a "$DEP_NOTIFY_APP" --args -path "$DEP_NOTIFY_LOG" -fullScreen elif [ "$FULLSCREEN" = false ]; then sudo -u "$CURRENT_USER" open -a "$DEP_NOTIFY_APP" --args -path "$DEP_NOTIFY_LOG" fi # Grabbing the DEP Notify Process ID for use later DEP_NOTIFY_PROCESS=$(pgrep -l "DEPNotify" | cut -d " " -f1) until [ "$DEP_NOTIFY_PROCESS" != "" ]; do echo "$(date "+%a %h %d %H:%M:%S"): Waiting for DEPNotify to start to gather the process ID." >> "$DEP_NOTIFY_DEBUG" sleep 1 DEP_NOTIFY_PROCESS=$(pgrep -l "DEPNotify" | cut -d " " -f1) done # Using Caffeinate binary to keep the computer awake if enabled # if [ "$NO_SLEEP" = true ]; then # echo "$(date "+%a %h %d %H:%M:%S"): Caffeinating DEP Notify process. Process ID: $DEP_NOTIFY_PROCESS" >> "$DEP_NOTIFY_DEBUG" # caffeinate -disu -w "$DEP_NOTIFY_PROCESS"& # fi # Adding an alert prompt to let admins know that the script is in testing mode if [ "$TESTING_MODE" = true ]; then echo "Command: Alert: DEP Notify befindet sich in TESTING_MODE. Das Skript führt keine Richtlinien oder andere Befehle aus, die Änderungen an diesem Computer vornehmen." >> "$DEP_NOTIFY_LOG" fi # Adding nice text and a brief pause for prettiness echo "Status: $INITAL_START_STATUS" >> "$DEP_NOTIFY_LOG" sleep 5 # Setting the status bar # Counter is for making the determinate look nice. Starts at one and adds # more based on EULA, register, or other options. ADDITIONAL_OPTIONS_COUNTER=1 if [ "$EULA_ENABLED" = true ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi if [ "$REGISTRATION_ENABLED" = true ]; then ((ADDITIONAL_OPTIONS_COUNTER++)) if [ "$REG_TEXT_LABEL_1" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi if [ "$REG_TEXT_LABEL_2" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi if [ "$REG_POPUP_LABEL_1" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi if [ "$REG_POPUP_LABEL_2" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi if [ "$REG_POPUP_LABEL_3" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi if [ "$REG_POPUP_LABEL_4" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi fi # Checking policy array and adding the count from the additional options above. ARRAY_LENGTH="$((${#POLICY_ARRAY[@]}+ADDITIONAL_OPTIONS_COUNTER))" echo "Command: Determinate: $ARRAY_LENGTH" >> "$DEP_NOTIFY_LOG" # EULA Window Display Logic if [ "$EULA_ENABLED" = true ]; then echo "Status: $EULA_STATUS" >> "$DEP_NOTIFY_LOG" echo "Command: ContinueButtonEULA: $EULA_BUTTON" >> "$DEP_NOTIFY_LOG" while [ ! -f "$DEP_NOTIFY_EULA_DONE" ]; do echo "$(date "+%a %h %d %H:%M:%S"): Waiting for user to accept EULA." >> "$DEP_NOTIFY_DEBUG" sleep 1 done fi # Registration Window Display Logic if [ "$REGISTRATION_ENABLED" = true ]; then echo "Status: $REGISTRATION_STATUS" >> "$DEP_NOTIFY_LOG" echo "Command: ContinueButtonRegister: $REGISTRATION_BUTTON" >> "$DEP_NOTIFY_LOG" while [ ! -f "$DEP_NOTIFY_REGISTER_DONE" ]; do echo "$(date "+%a %h %d %H:%M:%S"): Waiting for user to complete registration." >> "$DEP_NOTIFY_DEBUG" sleep 1 done # Running Logic For Each Registration Box if [ "$REG_TEXT_LABEL_1" != "" ]; then REG_TEXT_LABEL_1_LOGIC; fi if [ "$REG_TEXT_LABEL_2" != "" ]; then REG_TEXT_LABEL_2_LOGIC; fi if [ "$REG_POPUP_LABEL_1" != "" ]; then REG_POPUP_LABEL_1_LOGIC; fi if [ "$REG_POPUP_LABEL_2" != "" ]; then REG_POPUP_LABEL_2_LOGIC; fi if [ "$REG_POPUP_LABEL_3" != "" ]; then REG_POPUP_LABEL_3_LOGIC; fi if [ "$REG_POPUP_LABEL_4" != "" ]; then REG_POPUP_LABEL_4_LOGIC; fi fi # Loop to run policies for POLICY in "${POLICY_ARRAY[@]}"; do echo "Status: $(echo "$POLICY" | cut -d ',' -f1)" >> "$DEP_NOTIFY_LOG" if [ "$TESTING_MODE" = true ]; then sleep 2 elif [ "$TESTING_MODE" = false ]; then "$JAMF_BINARY" policy "-event" "$(echo "$POLICY" | cut -d ',' -f2)" fi done # Nice completion text echo "Status: $INSTALL_COMPLETE_TEXT" >> "$DEP_NOTIFY_LOG" ###################################################################################################### if [ "$COMPLETE_METHOD_DROPDOWN_ALERT" = true ] then echo "Command: Quit: $COMPLETE_ALERT_TEXT" >> "$DEP_NOTIFY_LOG" else echo "Command: MainText: $COMPLETE_MAIN_TEXT" >> "$DEP_NOTIFY_LOG" echo "Command: ContinueButton: $COMPLETE_BUTTON_TEXT" >> "$DEP_NOTIFY_LOG" fi exit 0