Posted on 10-27-2014 11:57 AM
Hi all,
I have a custom software update script (using parts of a script posted here on jamfnation) that checks for available software updates and displays different dialogs depending on the types of updates (e.g. restart required, critical software update, etc.). I've got it all correctly working now, except that when it actually successfully runs an update, it does not actually send the log to the JSS. If the user declines the update, then it successfully logs it to the JSS.
Am I doing something here that is preventing the JSS collection of the log?
Here's the code segment that ends the script:
forceUpdateName="OSXUpd10.9.5-10.9.5"
echo "Running softwareupdate -i $forceUpdateName &"
sudo softwareupdate -i $forceUpdateName &
#/usr/sbin/jamf policy -trigger SoftwareUpdate &
## Get the Process ID of the last command run in the background ($!) and wait for it to complete (wait)
SUPID=`echo "$!"`
wait $SUPID
echo "Updating JSS inventory..."
echo "Running sudo jamf recon"
sudo jamf recon
fSetSUStoApple
prompt=`sudo osascript << EOT
with timeout of 28800 seconds
tell app "Finder"
Activate
display dialog "Software Update completed. Your computer needs to be restarted. Would you like to restart now?" with title "Software Update Completed" buttons {"Restart Now", "Later"} default button 2 with icon file "Library:Application Support:JAMF:bin:SoftwareUpdate.icns"
end tell
end timeout
EOT`
userSelection=`echo $prompt | cut -d : -f 2`
if [ "$userSelection" == "Restart Now" ]; then
echo "User selected Restart Now"
echo "Running sudo shutdown -r now"
sudo shutdown -r now
else
echo "User selected Later"
echo "1" > /Library/Application Support/JAMF/.PendingRestart.txt
fi
exit 0
Thanks!
Posted on 10-27-2014 04:46 PM
I think I figured this out. If I execute sudo shutdown -r now, it doesn't have a chance to log. I've changed it to sudo shutdown -r +2