Setting up newly imaged system

totalyscrewedup
New Contributor III

Let me start by saying I had no training, no Jump start and Jamf Admin documentation is very limited on details.
I'm running Casper Suite 9.96 and I'm stuck with thick imaging since the 120 systems I have are of all ages but fully functional.
I've got the NetBoot image in place (10.12 since I can't get 10.10 to work with Casper Imaging), Prestage configuration is based on serial number (Changes computer name, Image automatically enabled, erases the drive, boots to it afterwards, uses admin account created from the configuration, installs 4 pkgs, runs the 2 scripts mentioned below, installs a printer and creates 2 local accounts ), Casper Imaging starts and it's deploying the dmg created with Autocaspernbi. The issue I'm having is running post imaging scripts and dock items from policy (Triggers used:)
Enrollment Complete, set to run once per computer). Specifically, the policy I have to execute the scripts is launching and executing but I'm getting mixed results. For one, one of the scripts is supposed to disable Wifi, another is supposed to enable cups, the dock items should be removed to bare minimum and it's supposed to check and install any updates (From Apple servers). 9db0d354fd004e52a6e827fb047e6e2d

What I end up is that cups is enabled but some dock items are replaced with '?', others aren't removed at all and wifi is still enabled.
Here is the script to disable wifi:
WFINT=$(networksetup -listallhardwareports | awk ' /Airport|Wi-Fi/ {getline; print $NF }')
if [ "$WFINT" != "" ]; then
echo "Disabling Wi-Fi on $WFINT"
networksetup -setairportpower $WFINT off
fi

What am I doing wrong?

5 REPLIES 5

blackholemac
Valued Contributor III

I've kinda given up on using Jamf's implementation and have taken to using dockutil (https://github.com/kcrawford/dockutil).

If you get this binary onto your Macs, it's a wizard at blanking and refilling the dock as you want with very simple straightforward scripting. check it out.

As for the Wifi, consider reformulating your syntax on the first line you provided:

WFINT=`networksetup -listallhardwareports | awk ' /Airport|Wi-Fi/ {getline; print $NF }'`

seann
Contributor

Dock management via Jamf isn't the best. You're better off using a launch agent script and dockutil

totalyscrewedup
New Contributor III

I've got the wifi disabled but now I can't get the dockutil to execute the following script (I've set it up to run 'at reboot' during prestage imaging):

!/bin/bash

/usr/local/bin/dockutil --remove 'Maps' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'Messages' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'Photos' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'Reminders' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'Calendar' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'Contacts' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'Launchpad' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'Mail' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'App Store' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'Siri' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'FaceTime' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'Safari' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'System Preferences' --allhomes --no-restart
/usr/local/bin/dockutil --remove 'iBooks' --allhomes --no-restart
/usr/local/bin/dockutil --add /Applications/Firefox.app --allhomes --no-restart
killall Dock

seann
Contributor

I run it only while someone is logged in. I'm not sure how well the allhomes flag works. I imagine it tries to modify a plist, probably in User Templates, which isn't protected by SIP but nonetheless I've never had much success with the flag.

dtommey
New Contributor III

I run dockutil on login (lookup Outset for this) so can't say if it works during prestage, however remove the -no-restart from your last dockutil command and you shouldn't need the killall Dock either.

My script looks like this...

#!/bin/sh

dockutilapp=/usr/local/bin/dockutil


$dockutilapp --remove all --no-restart

$dockutilapp --add "/Applications/Safari.app" --position end --no-restart
$dockutilapp --add "/Applications/Microsoft Excel.app" --position end --no-restart 
$dockutilapp --add "/Applications/Microsoft OneNote.app" --position end --no-restart
$dockutilapp --add "/Applications/Microsoft Outlook.app" --position end --no-restart
$dockutilapp --add "/Applications/Microsoft PowerPoint.app" --position end --no-restart
$dockutilapp --add "/Applications/Microsoft Word.app" --position end --no-restart
$dockutilapp --add "/Applications/Self Service.app" --position end --no-restart
$dockutilapp --add "/Applications/System Preferences.app" --position end --no-restart

$dockutilapp --add '/Applications/' --view grid --display folder --sort name --no-restart
$dockutilapp --add '~/Downloads' --view grid --display folder