Skip to content

Commit b83502b

Browse files
committed
Added check for Finder process to ensure that there is a current user
1 parent 0dcc1f7 commit b83502b

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

depNotify.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,25 @@
119119
fi
120120

121121
# Run DEP Notify will run after Apple Setup Assistant and must be run as the end user.
122+
SETUP_ASSISTANT_PROCESS=$(pgrep -l "Setup Assistant")
123+
until [ "$SETUP_ASSISTANT_PROCESS" = "" ]; do
124+
echo "$(date "+%a %h %d %H:%M:%S"): Setup Assistant Still Running. PID $SETUP_ASSISTANT_PROCESS." >> "$TMP_DEBUG_LOG"
125+
sleep 1
122126
SETUP_ASSISTANT_PROCESS=$(pgrep -l "Setup Assistant")
123-
until [ "$SETUP_ASSISTANT_PROCESS" = "" ]; do
124-
echo "$(date "+%a %h %d %H:%M:%S"): Setup Assistant Still Running. PID $SETUP_ASSISTANT_PROCESS." >> "$TMP_DEBUG_LOG"
125-
sleep 1
126-
SETUP_ASSISTANT_PROCESS=$(pgrep -l "Setup Assistant")
127-
done
127+
done
128+
129+
# Checking to see if the Finder is running now before continuing. This can help
130+
# in scenarios where an end user is not configuring the device.
131+
FINDER_PROCESS=$(pgrep -l "Finder")
132+
until [ "$FINDER_PROCESS" != "" ]; do
133+
echo "$(date "+%a %h %d %H:%M:%S"): Finder process not found. Assuming device is at login screen." >> "$TMP_DEBUG_LOG"
134+
sleep 1
135+
FINDER_PROCESS=$(pgrep -l "Finder")
136+
done
128137

129-
# After the Apple Setup completed. Now safe to grab the current user.
130-
CURRENT_USER=$(stat -f "%Su" "/dev/console")
131-
echo "$(date "+%a %h %d %H:%M:%S"): Current user set to $CURRENT_USER." >> "$TMP_DEBUG_LOG"
138+
# After the Apple Setup completed. Now safe to grab the current user.
139+
CURRENT_USER=$(stat -f "%Su" "/dev/console")
140+
echo "$(date "+%a %h %d %H:%M:%S"): Current user set to $CURRENT_USER." >> "$TMP_DEBUG_LOG"
132141

133142
# If SELF_SERVICE_CUSTOM_BRANDING is set to true. Loading the updated icon
134143
if [ "$SELF_SERVICE_CUSTOM_BRANDING" = true ]; then

0 commit comments

Comments
 (0)