11#! /bin/bash
2- # Version 2.0.5
2+ # Version 2.0.6
33
44# ########################################################################################
55# License information
@@ -519,9 +519,10 @@ TRIGGER="event"
519519 FINDER_PROCESS=$( pgrep -l " Finder" )
520520 done
521521
522- # After the Apple Setup completed. Now safe to grab the current user.
522+ # After the Apple Setup completed. Now safe to grab the current user and user ID
523523 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");' )
524- echo " $( date " +%a %h %d %H:%M:%S" ) : Current user set to $CURRENT_USER ." >> " $DEP_NOTIFY_DEBUG "
524+ CURRENT_USER_ID=$( id -u $CURRENT_USER )
525+ echo " $( date " +%a %h %d %H:%M:%S" ) : Current user set to $CURRENT_USER (id: $CURRENT_USER_ID )." >> " $DEP_NOTIFY_DEBUG "
525526
526527# Stop DEPNotify if there was already a DEPNotify window running (from a PreStage package postinstall script).
527528 PREVIOUS_DEP_NOTIFY_PROCESS=$( pgrep -l " DEPNotify" | cut -d " " -f1)
@@ -546,7 +547,8 @@ TRIGGER="event"
546547 echo " Command: MainTitle: $ERROR_BANNER_TITLE " >> " $DEP_NOTIFY_LOG "
547548 echo " Command: MainText: $ERROR_MAIN_TEXT " >> " $DEP_NOTIFY_LOG "
548549 echo " Status: $ERROR_STATUS " >> " $DEP_NOTIFY_LOG "
549- sudo -u " $CURRENT_USER " open -a " $DEP_NOTIFY_APP " --args -path " $DEP_NOTIFY_LOG "
550+ # # sudo -u "$CURRENT_USER" open -a "$DEP_NOTIFY_APP" --args -path "$DEP_NOTIFY_LOG"
551+ launchctl asuser $CURRENT_USER_ID open -a " $DEP_NOTIFY_APP " --args -path " $DEP_NOTIFY_LOG "
550552 sleep 5
551553 exit 1
552554 fi
@@ -558,6 +560,7 @@ TRIGGER="event"
558560 # Loop waiting on the branding image to properly show in the users library
559561 SELF_SERVICE_COUNTER=0
560562 CUSTOM_BRANDING_PNG=" /Users/$CURRENT_USER /Library/Application Support/com.jamfsoftware.selfservice.mac/Documents/Images/brandingimage.png"
563+
561564 until [ -f " $CUSTOM_BRANDING_PNG " ]; do
562565 echo " $( date " +%a %h %d %H:%M:%S" ) : Waiting for branding image from Jamf Pro." >> " $DEP_NOTIFY_DEBUG "
563566 sleep 1
@@ -575,6 +578,8 @@ TRIGGER="event"
575578 SELF_SERVICE_PID=$( pgrep -l " Self Service" | cut -d' ' -f1)
576579 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 "
577580 kill " $SELF_SERVICE_PID "
581+ elif [ -f " $BANNER_IMAGE_PATH " ]; then
582+ BANNER_IMAGE_PATH=" /Applications/Self Service.app/Contents/Resources/AppIcon.icns"
578583 fi
579584
580585# Setting custom image if specified
@@ -725,9 +730,11 @@ TRIGGER="event"
725730
726731# Opening the app after initial configuration
727732 if [ " $FULLSCREEN " = true ]; then
728- sudo -u " $CURRENT_USER " open -a " $DEP_NOTIFY_APP " --args -path " $DEP_NOTIFY_LOG " -fullScreen
733+ # # sudo -u "$CURRENT_USER" open -a "$DEP_NOTIFY_APP" --args -path "$DEP_NOTIFY_LOG" -fullScreen
734+ launchctl asuser $CURRENT_USER_ID open -a " $DEP_NOTIFY_APP " --args -path " $DEP_NOTIFY_LOG " -fullScreen
729735 elif [ " $FULLSCREEN " = false ]; then
730- sudo -u " $CURRENT_USER " open -a " $DEP_NOTIFY_APP " --args -path " $DEP_NOTIFY_LOG "
736+ # # sudo -u "$CURRENT_USER" open -a "$DEP_NOTIFY_APP" --args -path "$DEP_NOTIFY_LOG"
737+ launchctl asuser $CURRENT_USER_ID open -a " $DEP_NOTIFY_APP " --args -path " $DEP_NOTIFY_LOG "
731738 fi
732739
733740# Grabbing the DEP Notify Process ID for use later
0 commit comments