JAMF First Setup

#!/bin/bash

###############################################################################
# Name:    First Setup - with JamfHelper
# Version: 1.0
# Date:    19 september 2017
# Author:  Mischa van der Bent
# Purpose: show info to end user
###############################################################################

## Variabelen

model=`/usr/sbin/system_profiler SPHardwareDataType | grep 'Model Name:' | awk -F': ' '{print substr($2,1)}'`
LoggedInUser=`/usr/libexec/PlistBuddy -c "print :dsAttrTypeStandard\:RealName:0" /dev/stdin <<< "$(dscl -plist . -read /Users/$(stat -f%Su /dev/console) RealName)"`
ModelIcon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/com.apple.macbook-retina-space-gray.icns"
serialNumber=$(/usr/sbin/system_profiler SPHardwareDataType | awk '/Serial/ {print $4}')
shortname='whoami'

# JAMF Helper Variables
#######################################################################################################################
windowType="fs" # [hud | utility | fs]
windowPostion="ul" # [ul | ll | ur | lr]
iconSize="256" # pixels
alignDescription="center" # [right | left | center | justified | natural]
alignHeading="center" # [right | left | center | justified | natural]

# Screen 001 - Welcome
#######################################################################################################################
jhHeading="Congratulations ${LoggedInUser}"
jhDescription="Your ${model} with serialnumber ${serialNumber} is being configured.
This may take up to 5 minutes, depending on your network speed."
icon="/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/Assistant.icns"

"/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfhelper" \
-windowType "${windowType}" \
-title "${jhTitle}" \
-heading "${jhHeading}" \
-description "${jhDescription}" \
-icon "${icon}" \
-iconSize "128" \
-alignDescription "${alignDescription}" \
-alignHeading "${alignHeading}" &

Sleep 5

killall jamfhelper

# Screen 002 - Install Branding
#######################################################################################################################
jhHeading="Installing Expo2020 Branding"
jhDescription="On your ${model} the branding is being configured."
icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarCustomizeIcon.icns"

"/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfhelper" \
-windowType "${windowType}" \
-title "${jhTitle}" \
-heading "${jhHeading}" \
-description "${jhDescription}" \
-icon "$icon" \
-iconSize "$iconSize" \
-alignDescription "${alignDescription}" \
-alignHeading "${alignHeading}" &

/bin/echo "Install Branding"
jamf policy -id 8

#Sleep 5

killall jamfhelper

# Screen 100 - Install Google Chrome
#######################################################################################################################
jhHeading="Installing Google Chrome"
icon="/Library/Application Support/JAMF/bin/Branding/Chrome.png"


"/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfhelper" \
-windowType "${windowType}" \
-title "${jhTitle}" \
-heading "${jhHeading}" \
-description "Chrome is a fast, simple, and secure web browser, built for the modern web.
The latest version of Google Chrome is going to be installed on your ${model}." \
-icon "$icon" \
-iconSize "$iconSize" \
-alignDescription "${alignDescription}" \
-alignHeading "${alignHeading}" &

/bin/echo "Install Google Chrome"
jamf policy -id 10

#Sleep 5

killall jamfhelper

# Screen 101 - Setting User environment
#######################################################################################################################
jhHeading="Setting User environment"
icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns"

"/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfhelper" \
-windowType "${windowType}" \
-title "${jhTitle}" \
-heading "${jhHeading}" \
-description "All the default settings of Expo2020 is going to be setup on your ${model}"  \
-icon "$icon" \
-iconSize "$iconSize" \
-alignDescription "${alignDescription}" \
-alignHeading "${alignHeading}" &

## /bin/echo "Setting User environment"
## /bin/echo "Add Printers"
## jamf policy -id 7

## set WallPaper
/bin/echo "set WallPaper"
## osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/Library/Desktop Pictures/Expo2020.jpg"'
## osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/Library/Desktop Pictures/Expo2020-1.jpg"'
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/Library/Desktop Pictures/Expo2020-2.jpg"'

/bin/echo "enrollment is completed footprint"
sudo touch /Library/Application\ Support/JAMF/bin/completed.txt

## Update Inventory
/bin/echo "Update Inventory"
jamf recon

# Sleep 5

killall jamfhelper

# Screen 102 - Encrypting Hard Drive
#######################################################################################################################
#jhHeading="Encrypting Hard Drive"
#icon="/System/Library/PreferencePanes/Security.prefPane/Contents/Resources/FileVault.icns"

#"/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfhelper" \
#-windowType "${windowType}" \
#-title "${jhTitle}" \
#-heading "${jhHeading}" \
#-description "FileVault secures the data on your disk by encrypting its content automatically" \
#-icon "$icon" \
#-iconSize "$iconSize" \
#-alignDescription "${alignDescription}" \
#-alignHeading "${alignHeading}" &

## /bin/echo "Encrypting Hard Drive"
## jamf policy -id 31

## Update Inventory
## /bin/echo "Update Inventory"
## jamf recon

#Sleep 5

#killall jamfhelper

# Screen 999 - Complete
#######################################################################################################################
policyName="Enjoy your ${model} ${LoggedInUser}"
jhHeading="Enjoy your ${model} ${LoggedInUser}!"
icon="/Library/Application Support/JAMF/bin/Branding/Expo2020.png"

"/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfhelper" \
-windowType "${windowType}" \
-title "${jhTitle}" \
-heading " " \
-description "${jhHeading}"  \
-icon "$icon" \
-iconSize "128" \
-alignDescription "${alignDescription}" \
-alignHeading "${alignHeading}" &

sleep 10

killall jamfhelper
/bin/echo "Dock Settings"
jamf policy -id 11

## Quit QuickAdd
## killall Installer

## Log current user out
## /bin/echo "log current user out"
## osascript -e 'tell application "loginwindow" to  «event aevtrlgo»'

exit 0

Comments

Popular posts from this blog

Restore macOS Server from a Time Machine backup

JAMF Server Upgrade process

Creating a Custom Installer for Mac (PKG Package)