Posted on 07-14-2015 10:53 AM
I worked this out and can be used in a policy. Hope this helps someone out
#!/bin/bash
### Environment Variables ###
# For OS updates use OSXUpd
# For Security updates use SecUpd
# Get any OS updates
getosupd=$(softwareupdate -l | grep OSXupd | awk 'NR==1 {print $2}')
#Get any security updates
getsecupd=$(softwareupdate -l | grep SecUpd | awk 'NR==1 {print $2}')
### DO NOT MODIFY BELOW THIS LINE ###
# Install OS updates
softwareupdate -i $getosupd
# Install Security updates
softwareupdate -i $getsecupd
exit 0
~
~
Posted on 07-17-2015 09:04 AM
Nice job! I have this same setup but broken down into two separate scripts. Does the job quite well.
Posted on 07-17-2015 12:12 PM
@Snickasaurus Thanks
I have this modified version that goes install OS Updates & security updates with the added bonus if a restart is required a popup notifies the user.
Hope you find this useful
#!/bin/bash
### Environment Variables ###
# For OS updates use OSXUpd
# For Security updates use SecUpd
# Get any OS updates
getosupd=$(softwareupdate -l | grep OSXUpd | awk 'NR==1 {print $2}')
# Get any security updates
getsecupd=$(softwareupdate -l | grep SecUpd | awk 'NR==1 {print $2}')
MSG1='OS Software updates have been installed and require a restart. Please save your work and restart your machine'
MSG2='Security updates have been installed and require a restart. Please save your work and restart your machine'
### DO NOT MODIFY BELOW THIS LINE ###
# Install OS updates
if
softwareupdate -i $getosupd | grep "restart"
then
sudo /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper
-windowType utility -title "WARNING" -description "$MSG1" -icon /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertCautionIcon.icns -iconSize 96 -button1 "OK" -defaultButton 1
fi
# Install Security updates
if
softwareupdate -i $getsecupd | grep "restart"
then
sudo /Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper
-windowType utility -title "WARNING" -description "$MSG2" -icon /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertCautionIcon.icns -iconSize 96 -button1 "OK" -defaultButton 1
fi
exit 0
Posted on 07-20-2017 08:45 AM
Sorry - I am new to the JSS. Could you lay out in more detail how this was added to your policy?
Would I create the policy and then just copy and paste those commands into the File and Processes and an Execute Command?
Thank you!
Posted on 07-20-2017 08:49 AM
@spif_spaceman You'd create a Script in your JSS based on @tkimpton's post, then create a Policy with a Scripts payload that executes that script.
Posted on 07-20-2017 08:50 AM
Go to the settings and create this as a script and then run that script as a policy.
Posted on 07-20-2017 08:52 AM
Wow thank you guys for the quick responses!!!
Posted on 08-02-2017 07:09 AM
I'm also new to this world. Anyone got any ideas how i could run this when the App store requests credentials for the account? User doesn't know them, but I do.
Posted on 08-02-2017 07:20 AM
You could deploy Using Apple Volume Purchase Program, the Apps could then be assigned to device and no Apple ID required...
Worth a look.. https://volume.itunes.apple.com/gb/store
Posted on 08-21-2017 07:22 AM
@TKimpton I like your script and it worked on all two of the devices we tested it on. I needed to reimage the devices, and afterwards flushed the logs to allow the OS update to occur again. Now it is saying the OS update completed, but the OS never updates... even after 2 hrs. Thoughts or ideas JAMF crew?
Print out of log:
Executing Policy OS update Script
Running script OS Update Script...
Script exit code: 0
Script result:
Posted on 12-19-2017 11:33 AM
@tkimpton @Snickasaurus Hi folks! I'm thinking the above script is broken for Sierra? Yes? Its not doing anything for us. And it's setup as recommended above. Thoughts?
Posted on 06-15-2018 01:35 PM
Yep, it would not work for Sierra, when they changed the package names. You would need to go into the script and edit the environmental variables part
Posted on 11-14-2018 12:36 PM
How would I go about installing these updates but postponing the reboot until a specific time?
Posted on 12-06-2018 11:59 PM
Anyone got this working for Mojave ? nothing seems to happen
Posted on 07-23-2019 11:53 AM
is there a way to set a restart timer or count down?
Posted on 07-20-2021 10:27 AM
Guys, If I want to use this script on Catalina and BigSur OS versions, should I need to change something on the variables or the executed commands syntax?