Skip to content

Commit

Permalink
Added receipt checking and caffeinate to enrollment script to prevent…
Browse files Browse the repository at this point in the history
… extra policy checks
  • Loading branch information
Yohan460 committed Sep 10, 2018
1 parent 54e9300 commit bd2a066
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions Package Source Files/enrollmentScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Author: Johan McGwire - Yohan @ Macadmins Slack - [email protected]
#
# Description: This script is used to repeatedly call a policy trigger until removed and unloaded.
# Description: This script is used to reapeatdly call a policy trigger until removed and unloaded.

# Establishing the logging variables
LOGFOLDER="/var/log"
Expand Down Expand Up @@ -40,7 +40,7 @@ logme "======== Starting Configiration Policy Script ========"
while [ $(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }') == '_mbsetupuser' ]; do

# Logging the user lookup
logme "User Logged in check failed, waiting 10 seconds"
logme "User Logged in Check failed, waiting 10 seconds"

# Waiting
sleep 10
Expand Down Expand Up @@ -74,19 +74,25 @@ logme "Internet connection verified"
# Sleeping to ensure correct policy call
sleep 5

# Running the policy
logme "Calling the jamf policy with an InitialConfig trigger"
/usr/local/bin/jamf policy -trigger InitialConfig
returnCode=$?
if [[ ! -f "/Library/InitialConfiguration/.InitialConfigurationComplete" ]]; then

if [[ "${returnCode}" == "0" ]]; then
logme "Policy call successful"
# Running the policy
logme "Calling the jamf policy with an InitialConfig trigger"
caffeinate -disu bash -c '/usr/local/bin/jamf policy -trigger InitialConfig'
returnCode=$?

if [[ "${returnCode}" == "0" ]]; then
logme "Policy call successful"
else
logme "FAILED policy call"
fi
else
logme "FAILED policy call"

logme "Configuration Receipt present, Not calling setup policy"
fi

# Initializing log
logme "======== Finished Configiration Policy Script ========"

# Exiting and returning the policy call code (never actually reaches this point due to stoping after the reload)
exit $returnCode
exit $returnCode

0 comments on commit bd2a066

Please sign in to comment.