Hey all,
So in trying to use DEP for our new roll outs I'm struggling to recreate our policies that have up until this point been based on computer name. I think I can use DEPNotify and an attached script to call what I want to happen, however I have 2 specific things I want to write in.
I want to onlyhave it prompt me to fill in a name if its not already got a correct name. In our case names are building-position (or room number) and barcode. So for teacher machines its HS-Teacher12345. So Im trying to make logic that looks at the JSS and will tell if its generically named, or has gotten a name previously. If it previously has gotten a name, I want it to populate it with that name. I'm just not sure if putting it through DEP wipes the name when reimaging or if (like on iPads) once in the JSS it uses the name that JSS has saved instead of "MacBook Air".
I want to run extra policies in the script based on the name IE Admin/Teacher/Student
If anyone has any suggestions based on the attached script if I can make this logic happen, thanks in advance!
**Gabe Shackney
1#!/bin/bash2# Version 2.0.134#########################################################################################5# License information6#########################################################################################7# Copyright 2018 Jamf Professional Services89# Permission is hereby granted, free of charge, to any person obtaining a copy of this10# software and associated documentation files (the "Software"), to deal in the Software11# without restriction, including without limitation the rights to use, copy, modify, merge,12# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons13# to whom the Software is furnished to do so, subject to the following conditions:1415# The above copyright notice and this permission notice shall be included in all copies or16# substantial portions of the Software.1718# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,19# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR20# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE21# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR22# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER23# DEALINGS IN THE SOFTWARE.2425#########################################################################################26# General Information27#########################################################################################28# This script is designed to make implementation of DEPNotify very easy with limited29# scripting knowledge. The section below has variables that may be modified to customize30# the end user experience. DO NOT modify things in or below the CORE LOGIC area unless31# major testing and validation is performed.3233# More information at: https://github.com/jamfprofessionalservices/DEP-Notify3435#########################################################################################36# Testing Mode37#########################################################################################38# Testing flag will enable the following things to change:39# Auto removal of BOM files to reduce errors40# Sleep commands instead of policies or other changes being called41# Quit Key set to command + control + x42 TESTING_MODE=true # Set variable to true or false4344#########################################################################################45# General Appearance46#########################################################################################47# Flag the app to open fullscreen or as a window48 FULLSCREEN=true # Set variable to true or false4950# Banner image can be 600px wide by 100px high. Images will be scaled to fit51# If this variable is left blank, the generic image will appear. If using custom Self52# Service branding, please see the Customized Self Service Branding area below53 BANNER_IMAGE_PATH="/Applications/Self Service.app/Contents/Resources/AppIcon.icns"5455# Main heading that will be displayed under the image56# If this variable is left blank, the generic banner will appear57 BANNER_TITLE="Welcome to Princeton Public Schools!"5859# Paragraph text that will display under the main heading. For a new line, use 6061# If this variable is left blank, the generic message will appear. Leave single62# quotes below as double quotes will break the new lines.63 MAIN_TEXT='Imaging of this computer may take up to 30 minutes, please be stand by...'6465# Initial Start Status text that shows as things are firing up66 INITAL_START_STATUS="Initial Configuration Starting..."6768# Text that will display in the progress bar69 INSTALL_COMPLETE_TEXT="Configuration Complete!"7071# Complete messaging to the end user can ether be a button at the bottom of the72# app with a modification to the main window text or a dropdown alert box. Default73# value set to false and will use buttons instead of dropdown messages.74 COMPLETE_METHOD_DROPDOWN_ALERT=false # Set variable to true or false7576# Script designed to automatically logout user to start FileVault process if77# deferred enablement is detected. Text displayed if deferred status is on.78 # Option for dropdown alert box79 FV_ALERT_TEXT=""80 # Options if not using dropdown alert box81 FV_COMPLETE_MAIN_TEXT=''82 FV_COMPLETE_BUTTON_TEXT="Logout"8384# Text that will display inside the alert once policies have finished85 # Option for dropdown alert box86 COMPLETE_ALERT_TEXT="Your Mac is now finished with initial setup and configuration. Press Quit to get started!"87 # Options if not using dropdown alert box88 COMPLETE_MAIN_TEXT='Your Mac is now finished with initial setup and configuration.'89 COMPLETE_BUTTON_TEXT="Get Started!"9091#########################################################################################92# Plist Configuration93#########################################################################################94# The menu.depnotify.plist contains more and more things that configure the DEPNotify app95# You may want to save the file for purposes like verifying EULA acceptance or validating96# other options.9798# Plist Save Location99 # This wrapper allows variables that are created later to be used but also allow for100 # configuration of where the plist is stored101 INFO_PLIST_WRAPPER (){102 DEP_NOTIFY_USER_INPUT_PLIST="/Users/$CURRENT_USER/Library/Preferences/menu.nomad.DEPNotifyUserInput.plist"103 }104105# Status Text Alignment106 # The status text under the progress bar can be configured to be left, right, or center107 STATUS_TEXT_ALIGN="center"108109# Help Button Configuration110 # The help button was changed to a popup. Button will appear if title is populated.111 HELP_BUBBLE_TITLE="Need Help?"112 HELP_BUBBLE_BODY="Contact the Princeton Public School's Technology Office at 609-806-4299"113114#########################################################################################115# Error Screen Text116#########################################################################################117# If testing mode is false and configuration files are present, this text will appear to118# the end user and asking them to contact IT. Limited window options here as the119# assumption is that they need to call IT. No continue or exit buttons will show for120# DEP Notify window and it will not show in fullscreen. IT staff will need to use Terminal121# or Activity Monitor to kill DEP Notify.122123# Main heading that will be displayed under the image124 ERROR_BANNER_TITLE="Uh oh, Something Needs Fixing!"125126# Paragraph text that will display under the main heading. For a new line, use 127128# If this variable is left blank, the generic message will appear. Leave single129# quotes below as double quotes will break the new lines.130 ERROR_MAIN_TEXT='Something went wrong. Please contact the Princeton Public Schools Technology Office at 609-806-4299'131132# Error status message that is displayed under the progress bar133 ERROR_STATUS="Setup Failed"134135#########################################################################################136# Policy Variable to Modify137#########################################################################################138# The policy array must be formatted "Progress Bar text,customTrigger". These will be139# run in order as they appear below.140 POLICY_ARRAY=(141 "Installing Adobe Reader,adobeReader"142 "Installing Chrome,chrome"143 "Installing Firefox,firefox"144 "Installing Java,java"145 "Installing Office,msOffice"146 "Installing Critical Updates,updateSoftware"147 )148149#########################################################################################150# Caffeinate / No Sleep Configuration151#########################################################################################152# Flag script to keep the computer from sleeping. BE VERY CAREFUL WITH THIS FLAG!153# This flag could expose your data to risk by leaving an unlocked computer wide open.154# Only recommended if you are using fullscreen mode and have a logout taking place at155# the end of configuration (like for FileVault). Some folks may use this in workflows156# where IT staff are the primary people setting up the device. The device will be157# allowed to sleep again once the DEPNotify app is quit as caffeinate is looking158# at DEPNotify's process ID.159 NO_SLEEP=true160161#########################################################################################162# Customized Self Service Branding163#########################################################################################164# Flag for using the custom branding icon from Self Service and Jamf Pro165# This will override the banner image specified above. If you have changed the166# name of Self Service, make sure to modify the Self Service name below.167# Please note, custom branding is downloaded from Jamf Pro after Self Service has opened168# at least one time. The script is designed to wait until the files have been downloaded.169# This could take a few minutes depending on server and network resources.170 SELF_SERVICE_CUSTOM_BRANDING=true # Set variable to true or false171172# If using a name other than Self Service with Custom branding. Change the173# name with the SELF_SERVICE_APP_NAME variable below. Keep .app on the end174 SELF_SERVICE_APP_NAME="Self Service.app"175176#########################################################################################177# EULA Variables to Modify178#########################################################################################179# EULA configuration180 EULA_ENABLED=false # Set variable to true or false181182 # EULA status bar text183 EULA_STATUS="Waiting on completion of EULA acceptance"184185 # EULA button text on the main screen186 EULA_BUTTON="Read and Agree to EULA"187188 # EULA Screen Title189 EULA_MAIN_TITLE="Organization End User License Agreement"190191 # EULA Subtitle192 EULA_SUBTITLE="Please agree to the following terms and conditions to start configuration of this Mac"193194 # Path to the EULA file you would like the user to read and agree to. It is195 # best to package this up with Composer or another tool and deliver it to a196 # shared area like /Users/Shared/197 EULA_FILE_PATH="/Users/Shared/eula.txt"198199#########################################################################################200# Registration Variables to Modify201#########################################################################################202# Registration window configuration203 REGISTRATION_ENABLED=false # Set variable to true or false204205 # Registration window title206 REGISTRATION_TITLE="Register Mac at Organization"207208 # Registration status bar text209 REGISTRATION_STATUS="Waiting on completion of computer registration"210211 # Registration window submit or finish button text212 REGISTRATION_BUTTON="Register Your Mac"213214 # The text and pick list sections below will write the following lines out for215 # end users. Use the variables below to configure what the sentence says216 # Ex: Setting Computer Name to macBook0132217 REGISTRATION_BEGIN_WORD="Setting"218 REGISTRATION_MIDDLE_WORD="to"219220 # Registration window can have up to two text fields. Leaving the text display221 # variable empty will hide the input box. Display text is to the side of the222 # input and placeholder text is the gray text inside the input box.223 # Registration window can have up to four dropdown / pick list inputs. Leaving224 # the pick display variable empty will hide the dropdown / pick list.225226 # First Text Field227 #######################################################################################228 # Text Field Label229 REG_TEXT_LABEL_1="Computer Name"230231 # Place Holder Text232 REG_TEXT_LABEL_1_PLACEHOLDER="HS-TeacherBarcode"233234 # Optional flag for making the field an optional input for end user235 REG_TEXT_LABEL_1_OPTIONAL="false" # Set variable to true or false236237 # Help Bubble for Input. If title left blank, this will not appear238 REG_TEXT_LABEL_1_HELP_TITLE="Computer Name Field"239 REG_TEXT_LABEL_1_HELP_TEXT="This name must be set to the 2 letter abbreviation for your building, followed by a dash then either Teacher or Admin followed by the barcode of the computer."240241 # Logic below was put in this section rather than in core code as folks may242 # want to change what the field does. This is a function that gets called243 # when needed later on. BE VERY CAREFUL IN CHANGING THE FUNCTION!244 REG_TEXT_LABEL_1_LOGIC (){245 REG_TEXT_LABEL_1_VALUE=$(defaults read "$DEP_NOTIFY_USER_INPUT_PLIST" "$REG_TEXT_LABEL_1")246 if [ "$REG_TEXT_LABEL_1_OPTIONAL" = true ] && [ "$REG_TEXT_LABEL_1_VALUE" = "" ]; then247 echo "Status: $REG_TEXT_LABEL_1 was left empty. Skipping..." >> "$DEP_NOTIFY_LOG"248 echo "$(date "+%a %h %d %H:%M:%S"): $REG_TEXT_LABEL_1 was set to optional and was left empty. Skipping..." >> "$DEP_NOTIFY_DEBUG"249 sleep 5250 else251 echo "Status: $REGISTRATION_BEGIN_WORD $REG_TEXT_LABEL_1 $REGISTRATION_MIDDLE_WORD $REG_TEXT_LABEL_1_VALUE" >> "$DEP_NOTIFY_LOG"252 if [ "$TESTING_MODE" = true ]; then253 sleep 10254 else255 "$JAMF_BINARY" setComputerName -name "$REG_TEXT_LABEL_1_VALUE"256 sleep 5257 fi258 fi259 }260261 # Second Text Field262 #######################################################################################263 # Text Field Label264 REG_TEXT_LABEL_2="Barcode"265266 # Place Holder Text267 REG_TEXT_LABEL_2_PLACEHOLDER="XXXXX"268269 # Optional flag for making the field an optional input for end user270 REG_TEXT_LABEL_2_OPTIONAL="false" # Set variable to true or false271272 # Help Bubble for Input. If title left blank, this will not appear273 REG_TEXT_LABEL_2_HELP_TITLE="Barcode Field"274 #REG_TEXT_LABEL_2_HELP_TEXT="This field is used to give an updated asset tag to our asset management system. If you do not know your asset tag number, please skip this field."275276 # Logic below was put in this section rather than in core code as folks may277 # want to change what the field does. This is a function that gets called278 # when needed later on. BE VERY CAREFUL IN CHANGING THE FUNCTION!279 REG_TEXT_LABEL_2_LOGIC (){280 REG_TEXT_LABEL_2_VALUE=$(defaults read "$DEP_NOTIFY_USER_INPUT_PLIST" "$REG_TEXT_LABEL_2")281 if [ "$REG_TEXT_LABEL_2_OPTIONAL" = true ] && [ "$REG_TEXT_LABEL_2_VALUE" = "" ]; then282 echo "Status: $REG_TEXT_LABEL_2 was left empty. Skipping..." >> "$DEP_NOTIFY_LOG"283 echo "$(date "+%a %h %d %H:%M:%S"): $REG_TEXT_LABEL_2 was set to optional and was left empty. Skipping..." >> "$DEP_NOTIFY_DEBUG"284 sleep 5285 else286 echo "Status: $REGISTRATION_BEGIN_WORD $REG_TEXT_LABEL_2 $REGISTRATION_MIDDLE_WORD $REG_TEXT_LABEL_2_VALUE" >> "$DEP_NOTIFY_LOG"287 if [ "$TESTING_MODE" = true ]; then288 sleep 10289 else290 "$JAMF_BINARY" recon -assetTag "$REG_TEXT_LABEL_2_VALUE"291 fi292 fi293 }294295 # Popup 1296 #######################################################################################297 # Label for the popup298 REG_POPUP_LABEL_1=""299300 # Array of options for the user to select301 REG_POPUP_LABEL_1_OPTIONS=(302 "Amsterdam"303 "Eau Claire"304 "Minneapolis"305 )306307 # Help Bubble for Input. If title left blank, this will not appear308 REG_POPUP_LABEL_1_HELP_TITLE=""309 REG_POPUP_LABEL_1_HELP_TEXT="Please choose the appropriate building for where you normally work. This is important for inventory purposes."310311 # Logic below was put in this section rather than in core code as folks may312 # want to change what the field does. This is a function that gets called313 # when needed later on. BE VERY CAREFUL IN CHANGING THE FUNCTION!314 REG_POPUP_LABEL_1_LOGIC (){315 REG_POPUP_LABEL_1_VALUE=$(defaults read "$DEP_NOTIFY_USER_INPUT_PLIST" "$REG_POPUP_LABEL_1")316 echo "Status: $REGISTRATION_BEGIN_WORD $REG_POPUP_LABEL_1 $REGISTRATION_MIDDLE_WORD $REG_POPUP_LABEL_1_VALUE" >> "$DEP_NOTIFY_LOG"317 if [ "$TESTING_MODE" = true ]; then318 sleep 10319 else320 "$JAMF_BINARY" recon -building "$REG_POPUP_LABEL_1_VALUE"321 fi322 }323324 # Popup 2325 #######################################################################################326 # Label for the popup327 REG_POPUP_LABEL_2=""328329 # Array of options for the user to select330 REG_POPUP_LABEL_2_OPTIONS=(331 "Customer Onboarding"332 "Professional Services"333 "Sales Engineering"334 )335336 # Help Bubble for Input. If title left blank, this will not appear337 REG_POPUP_LABEL_2_HELP_TITLE="Department Dropdown Field"338 REG_POPUP_LABEL_2_HELP_TEXT="Please choose the appropriate department for where you normally work. This is important for inventory purposes."339340 # Logic below was put in this section rather than in core code as folks may341 # want to change what the field does. This is a function that gets called342 # when needed later on. BE VERY CAREFUL IN CHANGING THE FUNCTION!343 REG_POPUP_LABEL_2_LOGIC (){344 REG_POPUP_LABEL_2_VALUE=$(defaults read "$DEP_NOTIFY_USER_INPUT_PLIST" "$REG_POPUP_LABEL_2")345 echo "Status: $REGISTRATION_BEGIN_WORD $REG_POPUP_LABEL_2 $REGISTRATION_MIDDLE_WORD $REG_POPUP_LABEL_2_VALUE" >> "$DEP_NOTIFY_LOG"346 if [ "$TESTING_MODE" = true ]; then347 sleep 10348 else349 "$JAMF_BINARY" recon -department "$REG_POPUP_LABEL_2_VALUE"350 fi351 }352353 # Popup 3 - Code is here but currently unused354 #######################################################################################355 # Label for the popup356 REG_POPUP_LABEL_3=""357358 # Array of options for the user to select359 REG_POPUP_LABEL_3_OPTIONS=(360 "Option 1"361 "Option 2"362 "Option 3"363 )364365 # Help Bubble for Input. If title left blank, this will not appear366 REG_POPUP_LABEL_3_HELP_TITLE=""367 REG_POPUP_LABEL_3_HELP_TEXT="This dropdown is currently not in use. All code is here ready for you to use. It can also be hidden by removing the contents of the REG_POPUP_LABEL_3 variable."368369 # Logic below was put in this section rather than in core code as folks may370 # want to change what the field does. This is a function that gets called371 # when needed later on. BE VERY CAREFUL IN CHANGING THE FUNCTION!372 REG_POPUP_LABEL_3_LOGIC (){373 REG_POPUP_LABEL_3_VALUE=$(defaults read "$DEP_NOTIFY_USER_INPUT_PLIST" "$REG_POPUP_LABEL_3")374 echo "Status: $REGISTRATION_BEGIN_WORD $REG_POPUP_LABEL_3 $REGISTRATION_MIDDLE_WORD $REG_POPUP_LABEL_3_VALUE" >> "$DEP_NOTIFY_LOG"375 if [ "$TESTING_MODE" = true ]; then376 sleep 10377 else378 sleep 10379 fi380 }381382 # Popup 4 - Code is here but currently unused383 #######################################################################################384 # Label for the popup385 REG_POPUP_LABEL_4=""386387 # Array of options for the user to select388 REG_POPUP_LABEL_4_OPTIONS=(389 "Option 1"390 "Option 2"391 "Option 3"392 )393394 # Help Bubble for Input. If title left blank, this will not appear395 REG_POPUP_LABEL_4_HELP_TITLE=""396 3REG_POPUP_LABEL_4_HELP_TEXT="This dropdown is currently not in use. All code is here ready for you to use. It can also be hidden by removing the contents of the REG_POPUP_LABEL_4 variable."397398 # Logic below was put in this section rather than in core code as folks may399 # want to change what the field does. This is a function that gets called400 # when needed later on. BE VERY CAREFUL IN CHANGING THE FUNCTION!401 REG_POPUP_LABEL_4_LOGIC (){402 REG_POPUP_LABEL_4_VALUE=$(defaults read "$DEP_NOTIFY_USER_INPUT_PLIST" "$REG_POPUP_LABEL_4")403 echo "Status: $REGISTRATION_BEGIN_WORD $REG_POPUP_LABEL_4 $REGISTRATION_MIDDLE_WORD $REG_POPUP_LABEL_4_VALUE" >> "$DEP_NOTIFY_LOG"404 if [ "$TESTING_MODE" = true ]; then405 sleep 10406 else407 sleep 10408 fi409 }410411#########################################################################################412#########################################################################################413# Core Script Logic - Don't Change Without Major Testing414#########################################################################################415#########################################################################################416417# Variables for File Paths418 JAMF_BINARY="/usr/local/bin/jamf"419 FDE_SETUP_BINARY="/usr/bin/fdesetup"420 DEP_NOTIFY_APP="/Applications/Utilities/DEPNotify.app"421 DEP_NOTIFY_LOG="/var/tmp/depnotify.log"422 DEP_NOTIFY_DEBUG="/var/tmp/depnotifyDebug.log"423 DEP_NOTIFY_DONE="/var/tmp/com.depnotify.provisioning.done"424425# Pulling from Policy parameters to allow true/false flags to be set. More info426# can be found on https://www.jamf.com/jamf-nation/articles/146/script-parameters427# These will override what is specified in the script above.428 # Testing Mode429 if [ "$4" != "" ]; then TESTING_MODE="$4"; fi430 # Fullscreen Mode431 if [ "$5" != "" ]; then FULLSCREEN="$5"; fi432 # No Sleep / Caffeinate Mode433 if [ "$6" != "" ]; then NO_SLEEP="$6"; fi434 # Self Service Custom Branding435 if [ "$7" != "" ]; then SELF_SERVICE_CUSTOM_BRANDING="$7"; fi436 # Complete method dropdown or main screen437 if [ "$8" != "" ]; then COMPLETE_METHOD_DROPDOWN_ALERT="$8"; fi438 # EULA Mode439 if [ "$9" != "" ]; then EULA_ENABLED="$9"; fi440 # Registration Mode441 if [ "${10}" != "" ]; then REGISTRATION_ENABLED="${10}"; fi442443# Standard Testing Mode Enhancements444 if [ "$TESTING_MODE" = true ]; then445 # Removing old config file if present (Testing Mode Only)446 if [ -f "$DEP_NOTIFY_LOG" ]; then rm "$DEP_NOTIFY_LOG"; fi447 if [ -f "$DEP_NOTIFY_DONE" ]; then rm "$DEP_NOTIFY_DONE"; fi448 if [ -f "$DEP_NOTIFY_DEBUG" ]; then rm "$DEP_NOTIFY_DEBUG"; fi449 # Setting Quit Key set to command + control + x (Testing Mode Only)450 echo "Command: QuitKey: x" >> "$DEP_NOTIFY_LOG"451 fi452453# Validating true/false flags454 if [ "$TESTING_MODE" != true ] && [ "$TESTING_MODE" != false ]; then455 echo "$(date "+%a %h %d %H:%M:%S"): Testing configuration not set properly. Currently set to $TESTING_MODE. Please update to true or false." >> "$DEP_NOTIFY_DEBUG"456 exit 1457 fi458 if [ "$FULLSCREEN" != true ] && [ "$FULLSCREEN" != false ]; then459 echo "$(date "+%a %h %d %H:%M:%S"): Fullscreen configuration not set properly. Currently set to $FULLSCREEN. Please update to true or false." >> "$DEP_NOTIFY_DEBUG"460 exit 1461 fi462 if [ "$NO_SLEEP" != true ] && [ "$NO_SLEEP" != false ]; then463 echo "$(date "+%a %h %d %H:%M:%S"): Sleep configuration not set properly. Currently set to $NO_SLEEP. Please update to true or false." >> "$DEP_NOTIFY_DEBUG"464 exit 1465 fi466 if [ "$SELF_SERVICE_CUSTOM_BRANDING" != true ] && [ "$SELF_SERVICE_CUSTOM_BRANDING" != false ]; then467 echo "$(date "+%a %h %d %H:%M:%S"): Self Service Custom Branding configuration not set properly. Currently set to $SELF_SERVICE_CUSTOM_BRANDING. Please update to true or false." >> "$DEP_NOTIFY_DEBUG"468 exit 1469 fi470 if [ "$COMPLETE_METHOD_DROPDOWN_ALERT" != true ] && [ "$COMPLETE_METHOD_DROPDOWN_ALERT" != false ]; then471 echo "$(date "+%a %h %d %H:%M:%S"): Completion alert method not set properly. Currently set to $COMPLETE_METHOD_DROPDOWN_ALERT. Please update to true or false." >> "$DEP_NOTIFY_DEBUG"472 exit 1473 fi474 if [ "$EULA_ENABLED" != true ] && [ "$EULA_ENABLED" != false ]; then475 echo "$(date "+%a %h %d %H:%M:%S"): EULA configuration not set properly. Currently set to $EULA_ENABLED. Please update to true or false." >> "$DEP_NOTIFY_DEBUG"476 exit 1477 fi478 if [ "$REGISTRATION_ENABLED" != true ] && [ "$REGISTRATION_ENABLED" != false ]; then479 echo "$(date "+%a %h %d %H:%M:%S"): Registration configuration not set properly. Currently set to $REGISTRATION_ENABLED. Please update to true or false." >> "$DEP_NOTIFY_DEBUG"480 exit 1481 fi482483# Run DEP Notify will run after Apple Setup Assistant484 SETUP_ASSISTANT_PROCESS=$(pgrep -l "Setup Assistant")485 until [ "$SETUP_ASSISTANT_PROCESS" = "" ]; do486 echo "$(date "+%a %h %d %H:%M:%S"): Setup Assistant Still Running. PID $SETUP_ASSISTANT_PROCESS." >> "$DEP_NOTIFY_DEBUG"487 sleep 1488 SETUP_ASSISTANT_PROCESS=$(pgrep -l "Setup Assistant")489 done490491# Checking to see if the Finder is running now before continuing. This can help492# in scenarios where an end user is not configuring the device.493 FINDER_PROCESS=$(pgrep -l "Finder")494 until [ "$FINDER_PROCESS" != "" ]; do495 echo "$(date "+%a %h %d %H:%M:%S"): Finder process not found. Assuming device is at login screen." >> "$DEP_NOTIFY_DEBUG"496 sleep 1497 FINDER_PROCESS=$(pgrep -l "Finder")498 done499500# After the Apple Setup completed. Now safe to grab the current user.501 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 + "502");')503 echo "$(date "+%a %h %d %H:%M:%S"): Current user set to $CURRENT_USER." >> "$DEP_NOTIFY_DEBUG"504505# Adding Check and Warning if Testing Mode is off and BOM files exist506 if [[ ( -f "$DEP_NOTIFY_LOG" || -f "$DEP_NOTIFY_DONE" ) && "$TESTING_MODE" = false ]]; then507 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"508 mv "$DEP_NOTIFY_LOG" "/var/tmp/depnotify_old.log"509 echo "Command: MainTitle: $ERROR_BANNER_TITLE" >> "$DEP_NOTIFY_LOG"510 echo "Command: MainText: $ERROR_MAIN_TEXT" >> "$DEP_NOTIFY_LOG"511 echo "Status: $ERROR_STATUS" >> "$DEP_NOTIFY_LOG"512 sudo -u "$CURRENT_USER" open -a "$DEP_NOTIFY_APP" --args -path "$DEP_NOTIFY_LOG"513 sleep 5514 exit 1515 fi516517# If SELF_SERVICE_CUSTOM_BRANDING is set to true. Loading the updated icon518 if [ "$SELF_SERVICE_CUSTOM_BRANDING" = true ]; then519 open -a "/Applications/$SELF_SERVICE_APP_NAME" --hide520521 # Loop waiting on the branding image to properly show in the users library522 CUSTOM_BRANDING_PNG="/Users/$CURRENT_USER/Library/Application Support/com.jamfsoftware.selfservice.mac/Documents/Images/brandingimage.png"523 until [ -f "$CUSTOM_BRANDING_PNG" ]; do524 echo "$(date "+%a %h %d %H:%M:%S"): Waiting for branding image from Jamf Pro." >> "$DEP_NOTIFY_DEBUG"525 sleep 1526 done527528 # Setting Banner Image for DEP Notify to Self Service Custom Branding529 BANNER_IMAGE_PATH="$CUSTOM_BRANDING_PNG"530531 # Closing Self Service532 SELF_SERVICE_PID=$(pgrep -l "$(echo "$SELF_SERVICE_APP_NAME" | cut -d "." -f1)" | cut -d " " -f1)533 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"534 kill "$SELF_SERVICE_PID"535 fi536537# Setting custom image if specified538 if [ "$BANNER_IMAGE_PATH" != "" ]; then echo "Command: Image: $BANNER_IMAGE_PATH" >> "$DEP_NOTIFY_LOG"; fi539540# Setting custom title if specified541 if [ "$BANNER_TITLE" != "" ]; then echo "Command: MainTitle: $BANNER_TITLE" >> "$DEP_NOTIFY_LOG"; fi542543# Setting custom main text if specified544 if [ "$MAIN_TEXT" != "" ]; then echo "Command: MainText: $MAIN_TEXT" >> "$DEP_NOTIFY_LOG"; fi545546# General Plist Configuration547 # Calling function to set the INFO_PLIST_PATH548 INFO_PLIST_WRAPPER549550 # The plist information below551 DEP_NOTIFY_CONFIG_PLIST="/Users/$CURRENT_USER/Library/Preferences/menu.nomad.DEPNotify.plist"552553 # If testing mode is on, this will remove some old configuration files554 if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_CONFIG_PLIST" ]; then rm "$DEP_NOTIFY_CONFIG_PLIST"; fi555 if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_USER_INPUT_PLIST" ]; then rm "$DEP_NOTIFY_USER_INPUT_PLIST"; fi556557 # Setting default path to the plist which stores all the user completed info558 defaults write "$DEP_NOTIFY_CONFIG_PLIST" pathToPlistFile "$DEP_NOTIFY_USER_INPUT_PLIST"559560 # Setting status text alignment561 defaults write "$DEP_NOTIFY_CONFIG_PLIST" statusTextAlignment "$STATUS_TEXT_ALIGN"562563 # Setting help button564 if [ "$HELP_BUBBLE_TITLE" != "" ]; then565 defaults write "$DEP_NOTIFY_CONFIG_PLIST" helpBubble -array-add "$HELP_BUBBLE_TITLE"566 defaults write "$DEP_NOTIFY_CONFIG_PLIST" helpBubble -array-add "$HELP_BUBBLE_BODY"567 fi568569# EULA Configuration570 if [ "$EULA_ENABLED" = true ]; then571 DEP_NOTIFY_EULA_DONE="/var/tmp/com.depnotify.agreement.done"572573 # If testing mode is on, this will remove EULA specific configuration files574 if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_EULA_DONE" ]; then rm "$DEP_NOTIFY_EULA_DONE"; fi575576 # Writing title, subtitle, and EULA txt location to plist577 defaults write "$DEP_NOTIFY_CONFIG_PLIST" EULAMainTitle "$EULA_MAIN_TITLE"578 defaults write "$DEP_NOTIFY_CONFIG_PLIST" EULASubTitle "$EULA_SUBTITLE"579 defaults write "$DEP_NOTIFY_CONFIG_PLIST" pathToEULA "$EULA_FILE_PATH"580581 # Setting ownership of EULA file582 chown "$CURRENT_USER:staff" "$EULA_FILE_PATH"583 chmod 444 "$EULA_FILE_PATH"584 fi585586# Registration Plist Configuration587 if [ "$REGISTRATION_ENABLED" = true ]; then588 DEP_NOTIFY_REGISTER_DONE="/var/tmp/com.depnotify.registration.done"589590 # If testing mode is on, this will remove registration specific configuration files591 if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_REGISTER_DONE" ]; then rm "$DEP_NOTIFY_REGISTER_DONE"; fi592593 # Main Window Text Configuration594 defaults write "$DEP_NOTIFY_CONFIG_PLIST" registrationMainTitle "$REGISTRATION_TITLE"595 defaults write "$DEP_NOTIFY_CONFIG_PLIST" registrationButtonLabel "$REGISTRATION_BUTTON"596 defaults write "$DEP_NOTIFY_CONFIG_PLIST" registrationPicturePath "$BANNER_IMAGE_PATH"597598 # First Text Box Configuration599 if [ "$REG_TEXT_LABEL_1" != "" ]; then600 defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField1Label "$REG_TEXT_LABEL_1"601 defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField1Placeholder "$REG_TEXT_LABEL_1_PLACEHOLDER"602 defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField1IsOptional "$REG_TEXT_LABEL_1_OPTIONAL"603 # Code for showing the help box if configured604 if [ "$REG_TEXT_LABEL_1_HELP_TITLE" != "" ]; then605 defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField1Bubble -array-add "$REG_TEXT_LABEL_1_HELP_TITLE"606 defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField1Bubble -array-add "$REG_TEXT_LABEL_1_HELP_TEXT"607 fi608 fi609610 # Second Text Box Configuration611 if [ "$REG_TEXT_LABEL_2" != "" ]; then612 defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField2Label "$REG_TEXT_LABEL_2"613 defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField2Placeholder "$REG_TEXT_LABEL_2_PLACEHOLDER"614 defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField2IsOptional "$REG_TEXT_LABEL_2_OPTIONAL"615 # Code for showing the help box if configured616 if [ "$REG_TEXT_LABEL_2_HELP_TITLE" != "" ]; then617 defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField2Bubble -array-add "$REG_TEXT_LABEL_2_HELP_TITLE"618 defaults write "$DEP_NOTIFY_CONFIG_PLIST" textField2Bubble -array-add "$REG_TEXT_LABEL_2_HELP_TEXT"619 fi620 fi621622 # Popup 1623 if [ "$REG_POPUP_LABEL_1" != "" ]; then624 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton1Label "$REG_POPUP_LABEL_1"625 # Code for showing the help box if configured626 if [ "$REG_POPUP_LABEL_1_HELP_TITLE" != "" ]; then627 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu1Bubble -array-add "$REG_POPUP_LABEL_1_HELP_TITLE"628 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu1Bubble -array-add "$REG_POPUP_LABEL_1_HELP_TEXT"629 fi630 # Code for adding the items from the array above into the plist631 for REG_POPUP_LABEL_1_OPTION in "${REG_POPUP_LABEL_1_OPTIONS[@]}"; do632 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton1Content -array-add "$REG_POPUP_LABEL_1_OPTION"633 done634 fi635636 # Popup 2637 if [ "$REG_POPUP_LABEL_2" != "" ]; then638 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton2Label "$REG_POPUP_LABEL_2"639 # Code for showing the help box if configured640 if [ "$REG_POPUP_LABEL_2_HELP_TITLE" != "" ]; then641 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu2Bubble -array-add "$REG_POPUP_LABEL_2_HELP_TITLE"642 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu2Bubble -array-add "$REG_POPUP_LABEL_2_HELP_TEXT"643 fi644 # Code for adding the items from the array above into the plist645 for REG_POPUP_LABEL_2_OPTION in "${REG_POPUP_LABEL_2_OPTIONS[@]}"; do646 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton2Content -array-add "$REG_POPUP_LABEL_2_OPTION"647 done648 fi649650 # Popup 3651 if [ "$REG_POPUP_LABEL_3" != "" ]; then652 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton3Label "$REG_POPUP_LABEL_3"653 # Code for showing the help box if configured654 if [ "$REG_POPUP_LABEL_3_HELP_TITLE" != "" ]; then655 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu3Bubble -array-add "$REG_POPUP_LABEL_3_HELP_TITLE"656 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu3Bubble -array-add "$REG_POPUP_LABEL_3_HELP_TEXT"657 fi658 # Code for adding the items from the array above into the plist659 for REG_POPUP_LABEL_3_OPTION in "${REG_POPUP_LABEL_3_OPTIONS[@]}"; do660 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton3Content -array-add "$REG_POPUP_LABEL_3_OPTION"661 done662 fi663664 # Popup 4665 if [ "$REG_POPUP_LABEL_4" != "" ]; then666 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton4Label "$REG_POPUP_LABEL_4"667 # Code for showing the help box if configured668 if [ "$REG_POPUP_LABEL_4_HELP_TITLE" != "" ]; then669 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu4Bubble -array-add "$REG_POPUP_LABEL_4_HELP_TITLE"670 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupMenu4Bubble -array-add "$REG_POPUP_LABEL_4_HELP_TEXT"671 fi672 # Code for adding the items from the array above into the plist673 for REG_POPUP_LABEL_4_OPTION in "${REG_POPUP_LABEL_4_OPTIONS[@]}"; do674 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton4Content -array-add "$REG_POPUP_LABEL_4_OPTION"675 done676 fi677 fi678679# Changing Ownership of the plist file680 chown "$CURRENT_USER":staff "$DEP_NOTIFY_CONFIG_PLIST"681 chmod 600 "$DEP_NOTIFY_CONFIG_PLIST"682683# Opening the app after initial configuration684 if [ "$FULLSCREEN" = true ]; then685 sudo -u "$CURRENT_USER" open -a "$DEP_NOTIFY_APP" --args -path "$DEP_NOTIFY_LOG" -fullScreen686 elif [ "$FULLSCREEN" = false ]; then687 sudo -u "$CURRENT_USER" open -a "$DEP_NOTIFY_APP" --args -path "$DEP_NOTIFY_LOG"688 fi689690# Grabbing the DEP Notify Process ID for use later691 DEP_NOTIFY_PROCESS=$(pgrep -l "DEPNotify" | cut -d " " -f1)692 until [ "$DEP_NOTIFY_PROCESS" != "" ]; do693 echo "$(date "+%a %h %d %H:%M:%S"): Waiting for DEPNotify to start to gather the process ID." >> "$DEP_NOTIFY_DEBUG"694 sleep 1695 DEP_NOTIFY_PROCESS=$(pgrep -l "DEPNotify" | cut -d " " -f1)696 done697698# Using Caffeinate binary to keep the computer awake if enabled699 if [ "$NO_SLEEP" = true ]; then700 echo "$(date "+%a %h %d %H:%M:%S"): Caffeinating DEP Notify process. Process ID: $DEP_NOTIFY_PROCESS" >> "$DEP_NOTIFY_DEBUG"701 caffeinate -disu -w "$DEP_NOTIFY_PROCESS"&702 fi703704# Adding an alert prompt to let admins know that the script is in testing mode705 if [ "$TESTING_MODE" = true ]; then706 echo "Command: Alert: DEP Notify is in TESTING_MODE. Script will not run Policies or other commands that make change to this computer." >> "$DEP_NOTIFY_LOG"707 fi708709# Adding nice text and a brief pause for prettiness710 echo "Status: $INITAL_START_STATUS" >> "$DEP_NOTIFY_LOG"711 sleep 5712713# Setting the status bar714 # Counter is for making the determinate look nice. Starts at one and adds715 # more based on EULA, register, or other options.716 ADDITIONAL_OPTIONS_COUNTER=1717 if [ "$EULA_ENABLED" = true ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi718 if [ "$REGISTRATION_ENABLED" = true ]; then ((ADDITIONAL_OPTIONS_COUNTER++))719 if [ "$REG_TEXT_LABEL_1" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi720 if [ "$REG_TEXT_LABEL_2" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi721 if [ "$REG_POPUP_LABEL_1" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi722 if [ "$REG_POPUP_LABEL_2" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi723 if [ "$REG_POPUP_LABEL_3" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi724 if [ "$REG_POPUP_LABEL_4" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi725 fi726727 # Checking policy array and adding the count from the additional options above.728 ARRAY_LENGTH="$((${#POLICY_ARRAY[@]}+ADDITIONAL_OPTIONS_COUNTER))"729 echo "Command: Determinate: $ARRAY_LENGTH" >> "$DEP_NOTIFY_LOG"730731# EULA Window Display Logic732 if [ "$EULA_ENABLED" = true ]; then733 echo "Status: $EULA_STATUS" >> "$DEP_NOTIFY_LOG"734 echo "Command: ContinueButtonEULA: $EULA_BUTTON" >> "$DEP_NOTIFY_LOG"735 while [ ! -f "$DEP_NOTIFY_EULA_DONE" ]; do736 echo "$(date "+%a %h %d %H:%M:%S"): Waiting for user to accept EULA." >> "$DEP_NOTIFY_DEBUG"737 sleep 1738 done739 fi740741# Registration Window Display Logic742 if [ "$REGISTRATION_ENABLED" = true ]; then743 echo "Status: $REGISTRATION_STATUS" >> "$DEP_NOTIFY_LOG"744 echo "Command: ContinueButtonRegister: $REGISTRATION_BUTTON" >> "$DEP_NOTIFY_LOG"745 while [ ! -f "$DEP_NOTIFY_REGISTER_DONE" ]; do746 echo "$(date "+%a %h %d %H:%M:%S"): Waiting for user to complete registration." >> "$DEP_NOTIFY_DEBUG"747 sleep 1748 done749 # Running Logic For Each Registration Box750 if [ "$REG_TEXT_LABEL_1" != "" ]; then REG_TEXT_LABEL_1_LOGIC; fi751 if [ "$REG_TEXT_LABEL_2" != "" ]; then REG_TEXT_LABEL_2_LOGIC; fi752 if [ "$REG_POPUP_LABEL_1" != "" ]; then REG_POPUP_LABEL_1_LOGIC; fi753 if [ "$REG_POPUP_LABEL_2" != "" ]; then REG_POPUP_LABEL_2_LOGIC; fi754 if [ "$REG_POPUP_LABEL_3" != "" ]; then REG_POPUP_LABEL_3_LOGIC; fi755 if [ "$REG_POPUP_LABEL_4" != "" ]; then REG_POPUP_LABEL_4_LOGIC; fi756 fi757758# Loop to run policies759 for POLICY in "${POLICY_ARRAY[@]}"; do760 echo "Status: $(echo "$POLICY" | cut -d ',' -f1)" >> "$DEP_NOTIFY_LOG"761 if [ "$TESTING_MODE" = true ]; then762 sleep 10763 elif [ "$TESTING_MODE" = false ]; then764 "$JAMF_BINARY" policy -event "$(echo "$POLICY" | cut -d ',' -f2)"765 fi766 done767768# Nice completion text769 echo "Status: $INSTALL_COMPLETE_TEXT" >> "$DEP_NOTIFY_LOG"770771# Check to see if FileVault Deferred enablement is active772 FV_DEFERRED_STATUS=$($FDE_SETUP_BINARY status | grep "Deferred" | cut -d ' ' -f6)773774 # Logic to log user out if FileVault is detected. Otherwise, app will close.775 if [ "$FV_DEFERRED_STATUS" = "active" ] && [ "$TESTING_MODE" = true ]; then776 if [ "$COMPLETE_METHOD_DROPDOWN_ALERT" = true ]; then777 echo "Command: Quit: This is typically where your FV_LOGOUT_TEXT would be displayed. However, TESTING_MODE is set to true and FileVault deferred status is on." >> "$DEP_NOTIFY_LOG"778 else779 echo "Command: MainText: TESTING_MODE is set to true and FileVault deferred status is on. Button effect is quit instead of logout. 780 781 $FV_COMPLETE_MAIN_TEXT" >> "$DEP_NOTIFY_LOG"782 echo "Command: ContinueButton: Test $FV_COMPLETE_BUTTON_TEXT" >> "$DEP_NOTIFY_LOG"783 fi784 elif [ "$FV_DEFERRED_STATUS" = "active" ] && [ "$TESTING_MODE" = false ]; then785 if [ "$COMPLETE_METHOD_DROPDOWN_ALERT" = true ]; then786 echo "Command: Logout: $FV_ALERT_TEXT" >> "$DEP_NOTIFY_LOG"787 else788 echo "Command: MainText: $FV_COMPLETE_MAIN_TEXT" >> "$DEP_NOTIFY_LOG"789 echo "Command: ContinueButtonLogout: $FV_COMPLETE_BUTTON_TEXT" >> "$DEP_NOTIFY_LOG"790 fi791 else792 if [ "$COMPLETE_METHOD_DROPDOWN_ALERT" = true ]; then793 echo "Command: Quit: $COMPLETE_ALERT_TEXT" >> "$DEP_NOTIFY_LOG"794 else795 echo "Command: MainText: $COMPLETE_MAIN_TEXT" >> "$DEP_NOTIFY_LOG"796 echo "Command: ContinueButton: $COMPLETE_BUTTON_TEXT" >> "$DEP_NOTIFY_LOG"797 fi798 fi799800exit 0
Princeton Public Schools**