-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added receipt checking and caffeinate to enrollment script to prevent…
… extra policy checks
- Loading branch information
Showing
1 changed file
with
16 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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 | ||
|
@@ -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 |