-
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.
- Loading branch information
Showing
2 changed files
with
109 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>KeepAlive</key> | ||
<true/> | ||
<key>Label</key> | ||
<string>com.JAMF.InitialConfig</string> | ||
<key>ProgramArguments</key> | ||
<array> | ||
<string>sh</string> | ||
<string>/Library/InitialConfiguration/enrollmentScript.sh</string> | ||
</array> | ||
<key>RunAtLoad</key> | ||
<true/> | ||
</dict> | ||
</plist> |
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/bin/bash | ||
# | ||
# Author: Johan McGwire - Yohan @ Macadmins Slack - [email protected] | ||
# | ||
# Description: This script is used to reapeatdly call a policy trigger until removed and unloaded. | ||
|
||
# Establishing the logging variables | ||
LOGFOLDER="/var/log" | ||
LOGFILE="${LOGFOLDER}/Initial_Configuration_Policy_Call.log" | ||
|
||
if [ ! -d "$LOGFOLDER" ]; | ||
then | ||
/bin/mkdir "$LOGFOLDER" | ||
fi | ||
|
||
if [ ! -f "$LOGFILE" ]; | ||
then | ||
/usr/bin/touch ${LOGFILE} | ||
fi | ||
|
||
# Establishing the logging functionality | ||
function logme() | ||
{ | ||
# Check to see if function has been called correctly | ||
if [ -z "$1" ]; then | ||
/bin/echo "$(date '+%F %T') - logme function call error: no text passed to function! Please recheck code!" | ||
/bin/echo "$(date '+%F %T') - logme function call error: no text passed to function! Please recheck code!" >> ${LOGFILE} | ||
exit 1 | ||
fi | ||
|
||
# Log the passed details | ||
/bin/echo "$(date '+%F %T') - $1" | ||
/bin/echo "$(date '+%F %T') - $1" >> ${LOGFILE} | ||
} | ||
|
||
# Initializing log | ||
logme "======== Starting Configiration Policy Script ========" | ||
|
||
# Checking for the currently logged in user | ||
while [ $(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }') == '_mbsetupuser' ]; do | ||
|
||
# Logging the user lookup | ||
logme "User Check failed, waiting 10 seconds" | ||
|
||
# Waiting | ||
sleep 10 | ||
done | ||
|
||
logme "Logged in user: $(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')" | ||
logme "Running as: $(whoami)" | ||
|
||
# Checking for an internet connection | ||
returnCode=1 | ||
while [[ "${returnCode}" -ne "0" ]]; do | ||
|
||
# Loading google.com | ||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 | ||
returnCode=$? | ||
|
||
# Waiting | ||
if [[ "${returnCode}" -ne "0" ]]; then | ||
|
||
# Logging the user lookup | ||
logme "User Check failed, waiting 10 seconds" | ||
|
||
# Waiting | ||
sleep 10 | ||
|
||
fi | ||
done | ||
|
||
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 [[ "${returnCode}" == "0" ]]; then | ||
logme "Policy call successful" | ||
else | ||
logme "FAILED policy call" | ||
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 |