Skip to main content

I'm creating an installer to install the KACE agent on a Mac. I've gotten the installer to work correctly, but the issue is that I want to prompt the technician to rename the computer before it installs the KACE agent. Here's what I've got:



!/bin/bash



Prompt for computer name



ComputerName=`/usr/bin/osascript <<EOT
tell application "System Events"
activate
set ComputerName to text returned of (display dialog "Please Input New Computer Name" default answer "" with icon 2)
end tell
EOT`



Set New Computer Name



echo $ComputerName
scutil --set HostName $ComputerName
scutil --set LocalHostName $ComputerName
scutil --set ComputerName $ComputerName



echo Rename Successful



Installs KACE Agent



mkdir -p "/Library/Application Support/Quest/KACE/data"
sleep 15
sh -c 'KACE_SERVER=cu-k1100.eservices.virginia.edu installer -pkg AMPAgent_8.0.152.pkg -target /'



Forces inventory



<<'KBOT'
tell application "Terminal.app"
activate
delay 0.5
do shell script sudo("/Library/Application Support/Quest/KACE/bin/runkbot 1 0")
delay 1
do shell script sudo("/Library/Application Support/Quest/KACE/bin/runkbot 2 0")
end tell
KBOT



The issue is that the installer does not wait until the technician changes the computer name. I've tried separating the two steps into pre and post flight scripts, but it still doesn't wait.



So basically what I need to happen is Prompt For Computer Name > Update JAMF w/ Recon > Confirm Name Has Been Changed > Install KACE Agent.

Add a timeout to hold the process perhaps...



#!/bin/sh

ComputerName=`/usr/bin/osascript <<EOT
tell application "System Events"
activate
with timeout of 36000 seconds
set ComputerName to text returned of (display dialog "Please Input New Computer Name" default answer "" with icon 2)
end timeout
end tell
EOT`

You could have the install in a separate policy with a custom trigger. Once the name is set run jamf policy -event <customtrigger>.


@m.donovan I'm not entirely sure how to do that. I'm in the process of setting up JAMF for the first time and so it's not in production yet. I haven't used custom triggers as of yet.


Per this: http://www.filemaker.com/help/12/fmp/html/create_script.13.16.html



Apple Events has a native 2 minute time out. You can extend that using the "with timeout" function like so:



!/bin/bash



ComputerName=`/usr/bin/osascript << EOT
tell application "System Events"



with timeout of 60 seconds
activate



set ComputerName to text returned of (display dialog "Please Input New Computer Name (CU-XXXXXX)" default answer "CU-" with icon 2)



end timeout
end tell
EOT`



Set New Computer Name



echo $ComputerName
sudo scutil --set HostName $ComputerName
sudo scutil --set LocalHostName $ComputerName
sudo scutil --set ComputerName $ComputerName
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $ComputerName



echo "Rename Successful"



exit 0


Reply