Skip to content

Instantly share code, notes, and snippets.

@PinkShellos
Created April 27, 2022 19:34
Show Gist options
  • Save PinkShellos/38d8020ed298dab732449cf45e4a7c7d to your computer and use it in GitHub Desktop.
Save PinkShellos/38d8020ed298dab732449cf45e4a7c7d to your computer and use it in GitHub Desktop.
Example Jamf Connect Notify script
#!/bin/zsh
# Testing Mode
TESTING_MODE=true
#variables
NOTIFY_LOG="/var/tmp/depnotify.log"
JAMFBIN="/usr/local/bin/jamf"
MODEL_NAME=$(system_profiler SPHardwareDataType | awk '/Model Name/ {print $3}')
DONEFILE="/Users/Shared/.depNotifyDONE"
# Customization
ORG_NAME="Sterling Cooper"
CUSTOM_LOGO_PATH=""
CUSTOM_SELFSERV_NAME="" # Set if custom Self Service app name is set
WELCOME="Welcome to $ORG_NAME!"
SETUP_TXT="Your new $MODEL_NAME is enrolled into Jamf Pro and will be configured automatically.\n\nPlease allow 20-30 minutes for completion.\nOnce finished, you may sign in using your Star ID."
# Change variables based on customization
if [[ "$CUSTOM_SELFSERV_NAME" == "" ]]; then
SELFSERV_NAME="Self Service"
else
SELFSERV_NAME="$CUSTOM_SELFSERV_NAME"
fi
if [[ "$CUSTOM_LOGO_PATH" == "" ]]; then
LOGO_PATH="/Applications/$SELFSERV_NAME.app/Contents/Resources/AppIcon.icns"
else
LOGO_PATH="$CUSTOM_LOGO_PATH"
fi
# Jamf Policy Array
POLICY_ARRAY=(
"Installing Google Chrome...,installChrome"
"Installing Microsoft Excel...,installExcel"
"Installing Microsoft OneNote...,installOneNote"
"Installing Microsoft Outlook...,installOutlook"
"Installing Microsoft PowerPoint...,installPowerPoint"
"Installing Microsoft Teams...,installMicrosoftTeams"
"Installing Microsoft Word...,installWord"
"Installing Microsoft OneDrive...,installOneDrive"
"Installing Utilities...,installDockutil"
"Adding Default Dock Icons...,setDefaultDock"
)
# Welcome message, text, and Image
echo "STARTING RUN" >> $NOTIFY_LOG # Define the number of increments for the progress bar
ARRAY_LENGTH="${#POLICY_ARRAY[@]}" # Checking policy array length do determine step count
echo "Command: Determinate: $ARRAY_LENGTH" >> "$NOTIFY_LOG"
echo "Command: Image: $LOGO_PATH" >> "$NOTIFY_LOG"
echo "Command: MainTitle: $WELCOME" >> "$NOTIFY_LOG"
echo -e "Command: MainText: $SETUP_TXT" >> "$NOTIFY_LOG"
sleep 5
# Loop to run policies
if [[ $TESTING_MODE == false ]]; then
for POLICY in "${POLICY_ARRAY[@]}"; do
echo "Status: $(echo "$POLICY" | cut -d ',' -f1)" >> "$NOTIFY_LOG"
"$JAMFBIN" policy -event "$(echo "$POLICY" | cut -d ',' -f2)"
done
else
echo "Command: Alert: Notify Screen is in TESTING MODE. Script will not run Policies or other commands that make change to this computer." >> "$NOTIFY_LOG"
for POLICY in "${POLICY_ARRAY[@]}"; do
echo "Status: $(echo "$POLICY" | cut -d ',' -f1) (TESTING MODE)" >> "$NOTIFY_LOG"
sleep 10
done
fi
# Completion and DONEFILE placement
if [[ $TESTING_MODE == false ]]; then
/usr/bin/touch "$DONEFILE" # places DONEFILE for EA
/usr/local/bin/authchanger -reset -JamfConnect # resets loginwindow to Jamf Connect window without Notify
$JAMFBIN recon
else
echo "TESTING MODE enabled, do not add DONEFILE or reset loginwindow to remove PreAuth Notify Script run."
fi
echo -e "Command: Quit: Your new $MODEL_NAME is ready!\n\nPlease click \"Quit\" to proceed to login." >> "$NOTIFY_LOG"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment