Skip to main content
Question

Using DEPNotify but looking for some help scripting


Forum|alt.badge.img+18
  • Esteemed Contributor
  • 831 replies

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.

  1. 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".

  2. 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/bash
2# Version 2.0.1
3
4#########################################################################################
5# License information
6#########################################################################################
7# Copyright 2018 Jamf Professional Services
8
9# Permission is hereby granted, free of charge, to any person obtaining a copy of this
10# software and associated documentation files (the "Software"), to deal in the Software
11# 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 persons
13# to whom the Software is furnished to do so, subject to the following conditions:
14
15# The above copyright notice and this permission notice shall be included in all copies or
16# substantial portions of the Software.
17
18# 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 PARTICULAR
20# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
21# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23# DEALINGS IN THE SOFTWARE.
24
25#########################################################################################
26# General Information
27#########################################################################################
28# This script is designed to make implementation of DEPNotify very easy with limited
29# scripting knowledge. The section below has variables that may be modified to customize
30# the end user experience. DO NOT modify things in or below the CORE LOGIC area unless
31# major testing and validation is performed.
32
33# More information at: https://github.com/jamfprofessionalservices/DEP-Notify
34
35#########################################################################################
36# Testing Mode
37#########################################################################################
38# Testing flag will enable the following things to change:
39# Auto removal of BOM files to reduce errors
40# Sleep commands instead of policies or other changes being called
41# Quit Key set to command + control + x
42 TESTING_MODE=true # Set variable to true or false
43
44#########################################################################################
45# General Appearance
46#########################################################################################
47# Flag the app to open fullscreen or as a window
48 FULLSCREEN=true # Set variable to true or false
49
50# Banner image can be 600px wide by 100px high. Images will be scaled to fit
51# If this variable is left blank, the generic image will appear. If using custom Self
52# Service branding, please see the Customized Self Service Branding area below
53 BANNER_IMAGE_PATH="/Applications/Self Service.app/Contents/Resources/AppIcon.icns"
54
55# Main heading that will be displayed under the image
56# If this variable is left blank, the generic banner will appear
57 BANNER_TITLE="Welcome to Princeton Public Schools!"
58
59# Paragraph text that will display under the main heading. For a new line, use
60
61# If this variable is left blank, the generic message will appear. Leave single
62# 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...'
64
65# Initial Start Status text that shows as things are firing up
66 INITAL_START_STATUS="Initial Configuration Starting..."
67
68# Text that will display in the progress bar
69 INSTALL_COMPLETE_TEXT="Configuration Complete!"
70
71# Complete messaging to the end user can ether be a button at the bottom of the
72# app with a modification to the main window text or a dropdown alert box. Default
73# value set to false and will use buttons instead of dropdown messages.
74 COMPLETE_METHOD_DROPDOWN_ALERT=false # Set variable to true or false
75
76# Script designed to automatically logout user to start FileVault process if
77# deferred enablement is detected. Text displayed if deferred status is on.
78 # Option for dropdown alert box
79 FV_ALERT_TEXT=""
80 # Options if not using dropdown alert box
81 FV_COMPLETE_MAIN_TEXT=''
82 FV_COMPLETE_BUTTON_TEXT="Logout"
83
84# Text that will display inside the alert once policies have finished
85 # Option for dropdown alert box
86 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 box
88 COMPLETE_MAIN_TEXT='Your Mac is now finished with initial setup and configuration.'
89 COMPLETE_BUTTON_TEXT="Get Started!"
90
91#########################################################################################
92# Plist Configuration
93#########################################################################################
94# The menu.depnotify.plist contains more and more things that configure the DEPNotify app
95# You may want to save the file for purposes like verifying EULA acceptance or validating
96# other options.
97
98# Plist Save Location
99 # This wrapper allows variables that are created later to be used but also allow for
100 # configuration of where the plist is stored
101 INFO_PLIST_WRAPPER (){
102 DEP_NOTIFY_USER_INPUT_PLIST="/Users/$CURRENT_USER/Library/Preferences/menu.nomad.DEPNotifyUserInput.plist"
103 }
104
105# Status Text Alignment
106 # The status text under the progress bar can be configured to be left, right, or center
107 STATUS_TEXT_ALIGN="center"
108
109# Help Button Configuration
110 # 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"
113
114#########################################################################################
115# Error Screen Text
116#########################################################################################
117# If testing mode is false and configuration files are present, this text will appear to
118# the end user and asking them to contact IT. Limited window options here as the
119# assumption is that they need to call IT. No continue or exit buttons will show for
120# DEP Notify window and it will not show in fullscreen. IT staff will need to use Terminal
121# or Activity Monitor to kill DEP Notify.
122
123# Main heading that will be displayed under the image
124 ERROR_BANNER_TITLE="Uh oh, Something Needs Fixing!"
125
126# Paragraph text that will display under the main heading. For a new line, use
127
128# If this variable is left blank, the generic message will appear. Leave single
129# 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'
131
132# Error status message that is displayed under the progress bar
133 ERROR_STATUS="Setup Failed"
134
135#########################################################################################
136# Policy Variable to Modify
137#########################################################################################
138# The policy array must be formatted "Progress Bar text,customTrigger". These will be
139# 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 )
148
149#########################################################################################
150# Caffeinate / No Sleep Configuration
151#########################################################################################
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 at
155# the end of configuration (like for FileVault). Some folks may use this in workflows
156# where IT staff are the primary people setting up the device. The device will be
157# allowed to sleep again once the DEPNotify app is quit as caffeinate is looking
158# at DEPNotify's process ID.
159 NO_SLEEP=true
160
161#########################################################################################
162# Customized Self Service Branding
163#########################################################################################
164# Flag for using the custom branding icon from Self Service and Jamf Pro
165# This will override the banner image specified above. If you have changed the
166# 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 opened
168# 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 false
171
172# If using a name other than Self Service with Custom branding. Change the
173# name with the SELF_SERVICE_APP_NAME variable below. Keep .app on the end
174 SELF_SERVICE_APP_NAME="Self Service.app"
175
176#########################################################################################
177# EULA Variables to Modify
178#########################################################################################
179# EULA configuration
180 EULA_ENABLED=false # Set variable to true or false
181
182 # EULA status bar text
183 EULA_STATUS="Waiting on completion of EULA acceptance"
184
185 # EULA button text on the main screen
186 EULA_BUTTON="Read and Agree to EULA"
187
188 # EULA Screen Title
189 EULA_MAIN_TITLE="Organization End User License Agreement"
190
191 # EULA Subtitle
192 EULA_SUBTITLE="Please agree to the following terms and conditions to start configuration of this Mac"
193
194 # Path to the EULA file you would like the user to read and agree to. It is
195 # best to package this up with Composer or another tool and deliver it to a
196 # shared area like /Users/Shared/
197 EULA_FILE_PATH="/Users/Shared/eula.txt"
198
199#########################################################################################
200# Registration Variables to Modify
201#########################################################################################
202# Registration window configuration
203 REGISTRATION_ENABLED=false # Set variable to true or false
204
205 # Registration window title
206 REGISTRATION_TITLE="Register Mac at Organization"
207
208 # Registration status bar text
209 REGISTRATION_STATUS="Waiting on completion of computer registration"
210
211 # Registration window submit or finish button text
212 REGISTRATION_BUTTON="Register Your Mac"
213
214 # The text and pick list sections below will write the following lines out for
215 # end users. Use the variables below to configure what the sentence says
216 # Ex: Setting Computer Name to macBook0132
217 REGISTRATION_BEGIN_WORD="Setting"
218 REGISTRATION_MIDDLE_WORD="to"
219
220 # Registration window can have up to two text fields. Leaving the text display
221 # variable empty will hide the input box. Display text is to the side of the
222 # input and placeholder text is the gray text inside the input box.
223 # Registration window can have up to four dropdown / pick list inputs. Leaving
224 # the pick display variable empty will hide the dropdown / pick list.
225
226 # First Text Field
227 #######################################################################################
228 # Text Field Label
229 REG_TEXT_LABEL_1="Computer Name"
230
231 # Place Holder Text
232 REG_TEXT_LABEL_1_PLACEHOLDER="HS-TeacherBarcode"
233
234 # Optional flag for making the field an optional input for end user
235 REG_TEXT_LABEL_1_OPTIONAL="false" # Set variable to true or false
236
237 # Help Bubble for Input. If title left blank, this will not appear
238 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."
240
241 # Logic below was put in this section rather than in core code as folks may
242 # want to change what the field does. This is a function that gets called
243 # 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" = "" ]; then
247 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 5
250 else
251 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 ]; then
253 sleep 10
254 else
255 "$JAMF_BINARY" setComputerName -name "$REG_TEXT_LABEL_1_VALUE"
256 sleep 5
257 fi
258 fi
259 }
260
261 # Second Text Field
262 #######################################################################################
263 # Text Field Label
264 REG_TEXT_LABEL_2="Barcode"
265
266 # Place Holder Text
267 REG_TEXT_LABEL_2_PLACEHOLDER="XXXXX"
268
269 # Optional flag for making the field an optional input for end user
270 REG_TEXT_LABEL_2_OPTIONAL="false" # Set variable to true or false
271
272 # Help Bubble for Input. If title left blank, this will not appear
273 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."
275
276 # Logic below was put in this section rather than in core code as folks may
277 # want to change what the field does. This is a function that gets called
278 # 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" = "" ]; then
282 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 5
285 else
286 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 ]; then
288 sleep 10
289 else
290 "$JAMF_BINARY" recon -assetTag "$REG_TEXT_LABEL_2_VALUE"
291 fi
292 fi
293 }
294
295 # Popup 1
296 #######################################################################################
297 # Label for the popup
298 REG_POPUP_LABEL_1=""
299
300 # Array of options for the user to select
301 REG_POPUP_LABEL_1_OPTIONS=(
302 "Amsterdam"
303 "Eau Claire"
304 "Minneapolis"
305 )
306
307 # Help Bubble for Input. If title left blank, this will not appear
308 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."
310
311 # Logic below was put in this section rather than in core code as folks may
312 # want to change what the field does. This is a function that gets called
313 # 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 ]; then
318 sleep 10
319 else
320 "$JAMF_BINARY" recon -building "$REG_POPUP_LABEL_1_VALUE"
321 fi
322 }
323
324 # Popup 2
325 #######################################################################################
326 # Label for the popup
327 REG_POPUP_LABEL_2=""
328
329 # Array of options for the user to select
330 REG_POPUP_LABEL_2_OPTIONS=(
331 "Customer Onboarding"
332 "Professional Services"
333 "Sales Engineering"
334 )
335
336 # Help Bubble for Input. If title left blank, this will not appear
337 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."
339
340 # Logic below was put in this section rather than in core code as folks may
341 # want to change what the field does. This is a function that gets called
342 # 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 ]; then
347 sleep 10
348 else
349 "$JAMF_BINARY" recon -department "$REG_POPUP_LABEL_2_VALUE"
350 fi
351 }
352
353 # Popup 3 - Code is here but currently unused
354 #######################################################################################
355 # Label for the popup
356 REG_POPUP_LABEL_3=""
357
358 # Array of options for the user to select
359 REG_POPUP_LABEL_3_OPTIONS=(
360 "Option 1"
361 "Option 2"
362 "Option 3"
363 )
364
365 # Help Bubble for Input. If title left blank, this will not appear
366 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."
368
369 # Logic below was put in this section rather than in core code as folks may
370 # want to change what the field does. This is a function that gets called
371 # 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 ]; then
376 sleep 10
377 else
378 sleep 10
379 fi
380 }
381
382 # Popup 4 - Code is here but currently unused
383 #######################################################################################
384 # Label for the popup
385 REG_POPUP_LABEL_4=""
386
387 # Array of options for the user to select
388 REG_POPUP_LABEL_4_OPTIONS=(
389 "Option 1"
390 "Option 2"
391 "Option 3"
392 )
393
394 # Help Bubble for Input. If title left blank, this will not appear
395 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."
397
398 # Logic below was put in this section rather than in core code as folks may
399 # want to change what the field does. This is a function that gets called
400 # 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 ]; then
405 sleep 10
406 else
407 sleep 10
408 fi
409 }
410
411#########################################################################################
412#########################################################################################
413# Core Script Logic - Don't Change Without Major Testing
414#########################################################################################
415#########################################################################################
416
417# Variables for File Paths
418 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"
424
425# Pulling from Policy parameters to allow true/false flags to be set. More info
426# can be found on https://www.jamf.com/jamf-nation/articles/146/script-parameters
427# These will override what is specified in the script above.
428 # Testing Mode
429 if [ "$4" != "" ]; then TESTING_MODE="$4"; fi
430 # Fullscreen Mode
431 if [ "$5" != "" ]; then FULLSCREEN="$5"; fi
432 # No Sleep / Caffeinate Mode
433 if [ "$6" != "" ]; then NO_SLEEP="$6"; fi
434 # Self Service Custom Branding
435 if [ "$7" != "" ]; then SELF_SERVICE_CUSTOM_BRANDING="$7"; fi
436 # Complete method dropdown or main screen
437 if [ "$8" != "" ]; then COMPLETE_METHOD_DROPDOWN_ALERT="$8"; fi
438 # EULA Mode
439 if [ "$9" != "" ]; then EULA_ENABLED="$9"; fi
440 # Registration Mode
441 if [ "${10}" != "" ]; then REGISTRATION_ENABLED="${10}"; fi
442
443# Standard Testing Mode Enhancements
444 if [ "$TESTING_MODE" = true ]; then
445 # Removing old config file if present (Testing Mode Only)
446 if [ -f "$DEP_NOTIFY_LOG" ]; then rm "$DEP_NOTIFY_LOG"; fi
447 if [ -f "$DEP_NOTIFY_DONE" ]; then rm "$DEP_NOTIFY_DONE"; fi
448 if [ -f "$DEP_NOTIFY_DEBUG" ]; then rm "$DEP_NOTIFY_DEBUG"; fi
449 # Setting Quit Key set to command + control + x (Testing Mode Only)
450 echo "Command: QuitKey: x" >> "$DEP_NOTIFY_LOG"
451 fi
452
453# Validating true/false flags
454 if [ "$TESTING_MODE" != true ] && [ "$TESTING_MODE" != false ]; then
455 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 1
457 fi
458 if [ "$FULLSCREEN" != true ] && [ "$FULLSCREEN" != false ]; then
459 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 1
461 fi
462 if [ "$NO_SLEEP" != true ] && [ "$NO_SLEEP" != false ]; then
463 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 1
465 fi
466 if [ "$SELF_SERVICE_CUSTOM_BRANDING" != true ] && [ "$SELF_SERVICE_CUSTOM_BRANDING" != false ]; then
467 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 1
469 fi
470 if [ "$COMPLETE_METHOD_DROPDOWN_ALERT" != true ] && [ "$COMPLETE_METHOD_DROPDOWN_ALERT" != false ]; then
471 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 1
473 fi
474 if [ "$EULA_ENABLED" != true ] && [ "$EULA_ENABLED" != false ]; then
475 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 1
477 fi
478 if [ "$REGISTRATION_ENABLED" != true ] && [ "$REGISTRATION_ENABLED" != false ]; then
479 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 1
481 fi
482
483# Run DEP Notify will run after Apple Setup Assistant
484 SETUP_ASSISTANT_PROCESS=$(pgrep -l "Setup Assistant")
485 until [ "$SETUP_ASSISTANT_PROCESS" = "" ]; do
486 echo "$(date "+%a %h %d %H:%M:%S"): Setup Assistant Still Running. PID $SETUP_ASSISTANT_PROCESS." >> "$DEP_NOTIFY_DEBUG"
487 sleep 1
488 SETUP_ASSISTANT_PROCESS=$(pgrep -l "Setup Assistant")
489 done
490
491# Checking to see if the Finder is running now before continuing. This can help
492# in scenarios where an end user is not configuring the device.
493 FINDER_PROCESS=$(pgrep -l "Finder")
494 until [ "$FINDER_PROCESS" != "" ]; do
495 echo "$(date "+%a %h %d %H:%M:%S"): Finder process not found. Assuming device is at login screen." >> "$DEP_NOTIFY_DEBUG"
496 sleep 1
497 FINDER_PROCESS=$(pgrep -l "Finder")
498 done
499
500# 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"
504
505# Adding Check and Warning if Testing Mode is off and BOM files exist
506 if [[ ( -f "$DEP_NOTIFY_LOG" || -f "$DEP_NOTIFY_DONE" ) && "$TESTING_MODE" = false ]]; then
507 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 5
514 exit 1
515 fi
516
517# If SELF_SERVICE_CUSTOM_BRANDING is set to true. Loading the updated icon
518 if [ "$SELF_SERVICE_CUSTOM_BRANDING" = true ]; then
519 open -a "/Applications/$SELF_SERVICE_APP_NAME" --hide
520
521 # Loop waiting on the branding image to properly show in the users library
522 CUSTOM_BRANDING_PNG="/Users/$CURRENT_USER/Library/Application Support/com.jamfsoftware.selfservice.mac/Documents/Images/brandingimage.png"
523 until [ -f "$CUSTOM_BRANDING_PNG" ]; do
524 echo "$(date "+%a %h %d %H:%M:%S"): Waiting for branding image from Jamf Pro." >> "$DEP_NOTIFY_DEBUG"
525 sleep 1
526 done
527
528 # Setting Banner Image for DEP Notify to Self Service Custom Branding
529 BANNER_IMAGE_PATH="$CUSTOM_BRANDING_PNG"
530
531 # Closing Self Service
532 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 fi
536
537# Setting custom image if specified
538 if [ "$BANNER_IMAGE_PATH" != "" ]; then echo "Command: Image: $BANNER_IMAGE_PATH" >> "$DEP_NOTIFY_LOG"; fi
539
540# Setting custom title if specified
541 if [ "$BANNER_TITLE" != "" ]; then echo "Command: MainTitle: $BANNER_TITLE" >> "$DEP_NOTIFY_LOG"; fi
542
543# Setting custom main text if specified
544 if [ "$MAIN_TEXT" != "" ]; then echo "Command: MainText: $MAIN_TEXT" >> "$DEP_NOTIFY_LOG"; fi
545
546# General Plist Configuration
547 # Calling function to set the INFO_PLIST_PATH
548 INFO_PLIST_WRAPPER
549
550 # The plist information below
551 DEP_NOTIFY_CONFIG_PLIST="/Users/$CURRENT_USER/Library/Preferences/menu.nomad.DEPNotify.plist"
552
553 # If testing mode is on, this will remove some old configuration files
554 if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_CONFIG_PLIST" ]; then rm "$DEP_NOTIFY_CONFIG_PLIST"; fi
555 if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_USER_INPUT_PLIST" ]; then rm "$DEP_NOTIFY_USER_INPUT_PLIST"; fi
556
557 # Setting default path to the plist which stores all the user completed info
558 defaults write "$DEP_NOTIFY_CONFIG_PLIST" pathToPlistFile "$DEP_NOTIFY_USER_INPUT_PLIST"
559
560 # Setting status text alignment
561 defaults write "$DEP_NOTIFY_CONFIG_PLIST" statusTextAlignment "$STATUS_TEXT_ALIGN"
562
563 # Setting help button
564 if [ "$HELP_BUBBLE_TITLE" != "" ]; then
565 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 fi
568
569# EULA Configuration
570 if [ "$EULA_ENABLED" = true ]; then
571 DEP_NOTIFY_EULA_DONE="/var/tmp/com.depnotify.agreement.done"
572
573 # If testing mode is on, this will remove EULA specific configuration files
574 if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_EULA_DONE" ]; then rm "$DEP_NOTIFY_EULA_DONE"; fi
575
576 # Writing title, subtitle, and EULA txt location to plist
577 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"
580
581 # Setting ownership of EULA file
582 chown "$CURRENT_USER:staff" "$EULA_FILE_PATH"
583 chmod 444 "$EULA_FILE_PATH"
584 fi
585
586# Registration Plist Configuration
587 if [ "$REGISTRATION_ENABLED" = true ]; then
588 DEP_NOTIFY_REGISTER_DONE="/var/tmp/com.depnotify.registration.done"
589
590 # If testing mode is on, this will remove registration specific configuration files
591 if [ "$TESTING_MODE" = true ] && [ -f "$DEP_NOTIFY_REGISTER_DONE" ]; then rm "$DEP_NOTIFY_REGISTER_DONE"; fi
592
593 # Main Window Text Configuration
594 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"
597
598 # First Text Box Configuration
599 if [ "$REG_TEXT_LABEL_1" != "" ]; then
600 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 configured
604 if [ "$REG_TEXT_LABEL_1_HELP_TITLE" != "" ]; then
605 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 fi
608 fi
609
610 # Second Text Box Configuration
611 if [ "$REG_TEXT_LABEL_2" != "" ]; then
612 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 configured
616 if [ "$REG_TEXT_LABEL_2_HELP_TITLE" != "" ]; then
617 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 fi
620 fi
621
622 # Popup 1
623 if [ "$REG_POPUP_LABEL_1" != "" ]; then
624 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton1Label "$REG_POPUP_LABEL_1"
625 # Code for showing the help box if configured
626 if [ "$REG_POPUP_LABEL_1_HELP_TITLE" != "" ]; then
627 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 fi
630 # Code for adding the items from the array above into the plist
631 for REG_POPUP_LABEL_1_OPTION in "${REG_POPUP_LABEL_1_OPTIONS[@]}"; do
632 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton1Content -array-add "$REG_POPUP_LABEL_1_OPTION"
633 done
634 fi
635
636 # Popup 2
637 if [ "$REG_POPUP_LABEL_2" != "" ]; then
638 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton2Label "$REG_POPUP_LABEL_2"
639 # Code for showing the help box if configured
640 if [ "$REG_POPUP_LABEL_2_HELP_TITLE" != "" ]; then
641 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 fi
644 # Code for adding the items from the array above into the plist
645 for REG_POPUP_LABEL_2_OPTION in "${REG_POPUP_LABEL_2_OPTIONS[@]}"; do
646 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton2Content -array-add "$REG_POPUP_LABEL_2_OPTION"
647 done
648 fi
649
650 # Popup 3
651 if [ "$REG_POPUP_LABEL_3" != "" ]; then
652 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton3Label "$REG_POPUP_LABEL_3"
653 # Code for showing the help box if configured
654 if [ "$REG_POPUP_LABEL_3_HELP_TITLE" != "" ]; then
655 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 fi
658 # Code for adding the items from the array above into the plist
659 for REG_POPUP_LABEL_3_OPTION in "${REG_POPUP_LABEL_3_OPTIONS[@]}"; do
660 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton3Content -array-add "$REG_POPUP_LABEL_3_OPTION"
661 done
662 fi
663
664 # Popup 4
665 if [ "$REG_POPUP_LABEL_4" != "" ]; then
666 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton4Label "$REG_POPUP_LABEL_4"
667 # Code for showing the help box if configured
668 if [ "$REG_POPUP_LABEL_4_HELP_TITLE" != "" ]; then
669 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 fi
672 # Code for adding the items from the array above into the plist
673 for REG_POPUP_LABEL_4_OPTION in "${REG_POPUP_LABEL_4_OPTIONS[@]}"; do
674 defaults write "$DEP_NOTIFY_CONFIG_PLIST" popupButton4Content -array-add "$REG_POPUP_LABEL_4_OPTION"
675 done
676 fi
677 fi
678
679# Changing Ownership of the plist file
680 chown "$CURRENT_USER":staff "$DEP_NOTIFY_CONFIG_PLIST"
681 chmod 600 "$DEP_NOTIFY_CONFIG_PLIST"
682
683# Opening the app after initial configuration
684 if [ "$FULLSCREEN" = true ]; then
685 sudo -u "$CURRENT_USER" open -a "$DEP_NOTIFY_APP" --args -path "$DEP_NOTIFY_LOG" -fullScreen
686 elif [ "$FULLSCREEN" = false ]; then
687 sudo -u "$CURRENT_USER" open -a "$DEP_NOTIFY_APP" --args -path "$DEP_NOTIFY_LOG"
688 fi
689
690# Grabbing the DEP Notify Process ID for use later
691 DEP_NOTIFY_PROCESS=$(pgrep -l "DEPNotify" | cut -d " " -f1)
692 until [ "$DEP_NOTIFY_PROCESS" != "" ]; do
693 echo "$(date "+%a %h %d %H:%M:%S"): Waiting for DEPNotify to start to gather the process ID." >> "$DEP_NOTIFY_DEBUG"
694 sleep 1
695 DEP_NOTIFY_PROCESS=$(pgrep -l "DEPNotify" | cut -d " " -f1)
696 done
697
698# Using Caffeinate binary to keep the computer awake if enabled
699 if [ "$NO_SLEEP" = true ]; then
700 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 fi
703
704# Adding an alert prompt to let admins know that the script is in testing mode
705 if [ "$TESTING_MODE" = true ]; then
706 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 fi
708
709# Adding nice text and a brief pause for prettiness
710 echo "Status: $INITAL_START_STATUS" >> "$DEP_NOTIFY_LOG"
711 sleep 5
712
713# Setting the status bar
714 # Counter is for making the determinate look nice. Starts at one and adds
715 # more based on EULA, register, or other options.
716 ADDITIONAL_OPTIONS_COUNTER=1
717 if [ "$EULA_ENABLED" = true ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi
718 if [ "$REGISTRATION_ENABLED" = true ]; then ((ADDITIONAL_OPTIONS_COUNTER++))
719 if [ "$REG_TEXT_LABEL_1" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi
720 if [ "$REG_TEXT_LABEL_2" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi
721 if [ "$REG_POPUP_LABEL_1" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi
722 if [ "$REG_POPUP_LABEL_2" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi
723 if [ "$REG_POPUP_LABEL_3" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi
724 if [ "$REG_POPUP_LABEL_4" != "" ]; then ((ADDITIONAL_OPTIONS_COUNTER++)); fi
725 fi
726
727 # 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"
730
731# EULA Window Display Logic
732 if [ "$EULA_ENABLED" = true ]; then
733 echo "Status: $EULA_STATUS" >> "$DEP_NOTIFY_LOG"
734 echo "Command: ContinueButtonEULA: $EULA_BUTTON" >> "$DEP_NOTIFY_LOG"
735 while [ ! -f "$DEP_NOTIFY_EULA_DONE" ]; do
736 echo "$(date "+%a %h %d %H:%M:%S"): Waiting for user to accept EULA." >> "$DEP_NOTIFY_DEBUG"
737 sleep 1
738 done
739 fi
740
741# Registration Window Display Logic
742 if [ "$REGISTRATION_ENABLED" = true ]; then
743 echo "Status: $REGISTRATION_STATUS" >> "$DEP_NOTIFY_LOG"
744 echo "Command: ContinueButtonRegister: $REGISTRATION_BUTTON" >> "$DEP_NOTIFY_LOG"
745 while [ ! -f "$DEP_NOTIFY_REGISTER_DONE" ]; do
746 echo "$(date "+%a %h %d %H:%M:%S"): Waiting for user to complete registration." >> "$DEP_NOTIFY_DEBUG"
747 sleep 1
748 done
749 # Running Logic For Each Registration Box
750 if [ "$REG_TEXT_LABEL_1" != "" ]; then REG_TEXT_LABEL_1_LOGIC; fi
751 if [ "$REG_TEXT_LABEL_2" != "" ]; then REG_TEXT_LABEL_2_LOGIC; fi
752 if [ "$REG_POPUP_LABEL_1" != "" ]; then REG_POPUP_LABEL_1_LOGIC; fi
753 if [ "$REG_POPUP_LABEL_2" != "" ]; then REG_POPUP_LABEL_2_LOGIC; fi
754 if [ "$REG_POPUP_LABEL_3" != "" ]; then REG_POPUP_LABEL_3_LOGIC; fi
755 if [ "$REG_POPUP_LABEL_4" != "" ]; then REG_POPUP_LABEL_4_LOGIC; fi
756 fi
757
758# Loop to run policies
759 for POLICY in "${POLICY_ARRAY[@]}"; do
760 echo "Status: $(echo "$POLICY" | cut -d ',' -f1)" >> "$DEP_NOTIFY_LOG"
761 if [ "$TESTING_MODE" = true ]; then
762 sleep 10
763 elif [ "$TESTING_MODE" = false ]; then
764 "$JAMF_BINARY" policy -event "$(echo "$POLICY" | cut -d ',' -f2)"
765 fi
766 done
767
768# Nice completion text
769 echo "Status: $INSTALL_COMPLETE_TEXT" >> "$DEP_NOTIFY_LOG"
770
771# Check to see if FileVault Deferred enablement is active
772 FV_DEFERRED_STATUS=$($FDE_SETUP_BINARY status | grep "Deferred" | cut -d ' ' -f6)
773
774 # Logic to log user out if FileVault is detected. Otherwise, app will close.
775 if [ "$FV_DEFERRED_STATUS" = "active" ] && [ "$TESTING_MODE" = true ]; then
776 if [ "$COMPLETE_METHOD_DROPDOWN_ALERT" = true ]; then
777 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 else
779 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 fi
784 elif [ "$FV_DEFERRED_STATUS" = "active" ] && [ "$TESTING_MODE" = false ]; then
785 if [ "$COMPLETE_METHOD_DROPDOWN_ALERT" = true ]; then
786 echo "Command: Logout: $FV_ALERT_TEXT" >> "$DEP_NOTIFY_LOG"
787 else
788 echo "Command: MainText: $FV_COMPLETE_MAIN_TEXT" >> "$DEP_NOTIFY_LOG"
789 echo "Command: ContinueButtonLogout: $FV_COMPLETE_BUTTON_TEXT" >> "$DEP_NOTIFY_LOG"
790 fi
791 else
792 if [ "$COMPLETE_METHOD_DROPDOWN_ALERT" = true ]; then
793 echo "Command: Quit: $COMPLETE_ALERT_TEXT" >> "$DEP_NOTIFY_LOG"
794 else
795 echo "Command: MainText: $COMPLETE_MAIN_TEXT" >> "$DEP_NOTIFY_LOG"
796 echo "Command: ContinueButton: $COMPLETE_BUTTON_TEXT" >> "$DEP_NOTIFY_LOG"
797 fi
798 fi
799
800exit 0

Princeton Public Schools**

2 replies

Forum|alt.badge.img+8
  • Valued Contributor
  • 97 replies
  • July 29, 2019

You should look at the DEPNotify process I wrote. It also includes an Extension Attribute that pulls the computer record, checks if a value is populated, if not it will write it to the record. If the value is filled it will do nothing.

DEPNotify Launchd

General workflow:
1: Make a smart group called "Invalid Naming Scheme" and use Regex or hard code the values you DON'T want the machine name to have
2: Use the Jamf API to check if that computer is a member of the group
3: If it is, execute the policy to rename machine
4: Create an extension attribute to assign a group "Admin/Teacher/Student" based on the machine name
5: Make a script that executes a specific policy array based on the EA group

Alternatively, you can make multiple DEP assignments. We have one for Faculty/Staff and one for Lab/Checkouts. A smart group checks for membership of either of these and determines if something should be ran.

You can look at jmahlman's script to see how he handled policies based on a group (or cohort as he has it)


Forum|alt.badge.img+5
  • New Contributor
  • 3 replies
  • February 26, 2020

Hello gshackney,

This is how I am currently going about auto-naming the computers using the DEPNotify Starter script. I have added a few lines towards the bottom of the script to name the computer using our standard naming convention. Department prefix,D or L (laptop or desktop), and last 7 of the serial number. Once the user chooses the department that is then used for naming the computer. I hope this gives you some guidance on where to go with that or how to change me addition to make it work for you.

1 IS_LAPTOP=`/usr/sbin/system_profiler SPHardwareDataType | grep "Model Identifier" | grep "Book"`
2 serialNumber=$( system_profiler SPHardwareDataType | awk '/Serial Number/ { print $4; }')
3
4 if [ "$IS_LAPTOP" != "" ]; then
5 /usr/local/bin/jamf setComputerName -name "${REG_POPUP_LABEL_2_VALUE}-L${serialNumber: -7}"
6 else
7 /usr/local/bin/jamf setComputerName -name "${REG_POPUP_LABEL_2_VALUE}-D${serialNumber: -7}"
8 fi

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings