JAMFhelper Script Output

freddie_cox
Contributor III

I currently have a trigger which is called by a self service policy to unjoin from AD, rename the machine and rejoin it on our domain.

I would like for our techs to receive some type of status update while the script is running.

So far, I have tried running jamfhelper in the background and pulling status updates from variables but I am getting mixed results with empty helper windows opening, not closing even when killall jamfHelper is passed, etc.

Ideally, I woud love to have a window open up with a live preview of what is happening in the script. Has anyone been successful in this?

I can attach the script, but it is still a work in progress and not commented very well. :-)

8 REPLIES 8

jarednichols
Honored Contributor

Post it up.

nessts
Valued Contributor II

get rid of jamfhelper, and use cocoa dialog
you can do a progress bar, display bubble notices besides the status bar, whatever you want to do.
http://mstratman.github.com/cocoadialog/

freddie_cox
Contributor III

Update: New Script Posted Below

mm2270
Legendary Contributor III

If you're able to pump status output into a variable that you can drop into the jamfHelper, I would consider using the -timeout option instead of attempting to kill it repeatedly.

Something like a while loop as long as the script is running:

/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -description "$variable" -timeout 1

That will just keep making the window vanish and reappear with (potentially) new status information. I'm just guessing that this will even work. Haven't tested that of course.

charles_hitch
Contributor II

@freddie.cox, we are doing nearly the same thing (QAS and all). Having very mixed success. We are unbinding and rebinding with the same name, but with different options for vastool to change some of the computer object attributes. I have sleep for 15 minutes after the system unbinds to ensure our AD has time to sync out the change (learned that was needed the hard way). I was using full screen jamfHelper window and found that it wouldn't kill either. My next attempt was going to just reboot the system when done to ensure the jamfHelper really goes away. Interested to know what you come up with.

freddie_cox
Contributor III

@mm2270 - Somehow I missed the -timeout option #headdesk I will give that a shot to see how that goes.

@charles.hitch We had the 15 minute replication issue with QAS Mac binds, even put in a support call to quest, after an update and tweaking our replication. I'm trying to find the fix we applied for this but have been unsuccessful thus far. I will let you know if I find it.

freddie_cox
Contributor III

@charles.hitch http://www.frickelsoft.net/blog/?p=145 Take a look at this and see if it fits in your environment. We have a dedicated 1GB connection between sites so this helped us out quite a bit.

freddie_cox
Contributor III

Per @nessts suggestion I looked at CocoaDialog. This is a proof of concept that I like. Still not 100% what I was hoping for, but at least gives our techs something to relay to me should something break.

#!/bin/bash
#Freddie Cox for Knox County Schools
#July 2012

##CocoaDialog Preferences
#Path
CocoaDialog="/Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog"
#Icons
heart="/Applications/CocoaDialog.app/Contents/Resources/heart.icns"
gear="/Applications/CocoaDialog.app/Contents/Resources/gear.icns"

##Clear Old Logs
rm -rf /tmp/rename.log

#Open AppleScript Window to Prompt for new 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`

#Check to see if user messed up
if [$ComputerName = ""]; then
    echo "User Canceled Name Change" 2>&1
else

##Remove Computer from Domain
$CocoaDialog bubble --title "Computer Rename" --text "Unjoining Computer" --icon-file $gear &
/opt/quest/bin/vastool -u username -w password unjoin -f 2>&1 | tee /tmp/rename.log

#Set New Computer Name
echo $ComputerName
scutil --set HostName $ComputerName
scutil --set LocalHostName $ComputerName
scutil --set ComputerName $ComputerName

#Rejoin Domain with new computer name
$CocoaDialog bubble --title "Computer Rename" --text "Re-joining Computer" --icon-file $gear &

#Note: This takes a long time, would love to update user during this process
/opt/quest/bin/vastool -u username -w password join -wf domainname 2>&1 | tee /tmp/rename.log

#Output to Users
$CocoaDialog textbox --title "Script Output" --informative-text "Log Output Below - Check for Any Problems" --text-from-file /tmp/rename.log --button1 "Finished"
fi 

if [ $? = 1 ]; then 
    echo "Complete"
    else
fi