Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A script to install all required Software Updates System
After a version of OS X matures, it can be a pain to sit through several rounds of updates if you need to rebuild a machine from scratch. You install one set of updates, the machine restarts, and then the next set of updates pops-up. After a few cycles, this gets really old.

To work around that problem, I created a shell script that runs Software Update, installs all available updates, reboots, and repeats the process until there are no more updates left.

#!/bin/sh
# This script will run softwareupdate, install all available updates, reboot and repeat
# until no more updates are available. It must be run as root.
# To use in its current form, name the script initswupdater.sh and put it in /Library/Management.
# Tested in both Tiger and Leopard.

if [ -e /Users/Shared/.initswupd_inprog ]
then
    # If the 'updates in progress' marker is there, run the updates.
    # Temporarily prevent machine from sleeping.
    pmset -a sleep 0 force
    # Install all available software updates.
    softwareupdate -ai
    # Run softwareupdate again to see if there's anything left.
    # Softwareupdate returns 3 lines if there are no updates.
    if [ `softwareupdate -l | wc -l` -le 3 ]
    then
        # If there are no more updates available, clean up the marker, launchdaemon and login window text.
        rm /Users/Shared/.initswupd_inprog
        rm /Library/LaunchDaemons/com.management.initswupdater.plist
        defaults delete /Library/Preferences/com.apple.loginwindow LoginwindowText
    fi
else
    # If the 'updates in progress' marker is not there, prep the machine.
    # Create the marker file so the script knows to keep going.
    touch /Users/Shared/.initswupd_inprog
    #Set the loginwindow banner to warn people not to use the machine.
    defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "Software updates are currently being installed on this computer. Please do not attempt to log in until this message is gone."
    #Put the daemon in the LaunchDaemons folder, so the script runs again after reboot.
    plistfile='<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n<dict>\n<key>Label</key>\n<string>com.management.initswupdater</string>\n<key>ProgramArguments</key>\n<array>\n<string>/bin/sh</string><string>/Library/Management/initswupdater.sh</string>\n</array>\n<key>RunAtLoad</key>\n<true/>\n</dict>\n</plist>'
    # Writing the LaunchDaemon plist file must be done differently in Tiger than Leopard
    osversionlong=`sw_vers -productVersion`
    osvers=${osversionlong:3:1}
    if [ $osvers -eq 4 ]
    then
        # Tiger
        echo -e $plistfile > "/Library/LaunchDaemons/com.management.initswupdater.plist"
    else
        # Leopard
        echo $plistfile > "/Library/LaunchDaemons/com.management.initswupdater.plist"
    fi
fi
# Reboot
shutdown -r now
[robg adds: I haven't tested this one yet, but I've got it marked for the next time I go through this process. To make it work, remember to make it executable: chmod a+x initswupdater.sh. Update: Please read the comments for more-thorough installation and usage instructions.]
    •    
  • Currently 2.50 / 5
  You rated: 3 / 5 (12 votes cast)
 
[30,331 views]  

A script to install all required Software Updates | 33 comments | Create New Account
Click here to return to the 'A script to install all required Software Updates' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to install all required Software Updates
Authored by: metiure on Sep 19, '08 10:49:42AM

Interesting, but what about combo updates?



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: phillymjs on Sep 19, '08 08:20:12PM

Combo updates don't include everything. When you rebuild a Tiger machine from scratch, for example, there's Quicktime, iTunes, Java... many of which don't show up in Software Update until a prerequisite update is installed. This script just keeps installing and rebooting until there's nothing left.

---
Need Mac support for a business in the Philadelphia, PA metro area? Contact me.



[ Reply to This | # ]
Worked on Leopard, but not on Tiger
Authored by: alastor933 on Feb 21, '09 07:50:11AM

I used this with great success on a new install of Leopard, a few weeks ago.
Yesterday I tried it on a fresh Tiger install, with no luck.

The script runs, and the Mac reboots right away. When the startup window comes up it reboots again before the window is fully up. The 2nd time it boots 'normally'; no message in login window, no updates installed.

Any help would be appreciated - I know next to nothing of UNIX, but using Terminal doesn't scare me.

Thanks.



[ Reply to This | # ]
Worked on Leopard, but not on Tiger
Authored by: mcjohn87 on Aug 10, '09 12:01:49AM


Great work .. really informative .. and thanks a lot for sharing ..
[url=http://globolstaff.com/][color=#FFFFFF][u]script install[/u][/color][/url]

[ Reply to This | # ]
Help for a dummy?
Authored by: slb on Sep 19, '08 11:27:20AM

Can someone please explain how to do this in some steps for a dummy?
Looks like a great hint, but I want to make sure I do this correctly.
Thanks!



[ Reply to This | # ]
Help for a dummy?
Authored by: phillymjs on Sep 19, '08 08:27:23PM

If you want to use the script as-is, with no editing:

1. Create a "Management" folder in /Library.
2. Copy and paste the script into a plain text TextEdit document.
3. Save the script as "initswupdater.sh" in the /Library/Management folder.
4. Do "chmod a+x initswupdater.sh" in Terminal to make it executable.

To run it, do "sudo /Library/Management/initswupdater.sh" in Terminal.

---
Need Mac support for a business in the Philadelphia, PA metro area? Contact me.



[ Reply to This | # ]
Help for a dummy?
Authored by: mcjohn87 on Aug 10, '09 12:05:22AM
Great work .. really informative .. and thanks a lot for sharing ..
[url=http://globolstaff.com/][color=#FFFFFF][u]script install[/u][/color][/url]

[ Reply to This | # ]
A script to install all required Software Updates
Authored by: babbage on Sep 19, '08 12:36:27PM

This would be an obvious & welcome enhancement to Applejack.

Have you considered submitting a patch to it?

You should, this script represents a really good idea.

---

--
DO NOT LEAVE IT IS NOT REAL



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: packhater on Sep 19, '08 01:39:03PM

I don't see a /Library/Management folder on my Leopard machine. Also, what if there is already a loginwindow.plist file? Doesn't this script delete it then create its own? Not good if you already have one! :)



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: phillymjs on Sep 19, '08 08:32:45PM

Sorry, I should have been more clear. You have to make the Management folder in /Library, or you can edit the script in a few places to put it in a different location of your choosing.

The loginwindow.plist file is not overwritten. I just add and delete the LoginwindowText attribute. If you already have a disclaimer or something set as your login window text, the script could be edited to save any existing contents of LoginwindowText to a file and then put it back the way it was when the updating process completes. That is left as an exercise for the reader. :-)

---
Need Mac support for a business in the Philadelphia, PA metro area? Contact me.



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: rpaege on Sep 19, '08 02:52:46PM

I'm not normally one to complain because I've gotten so many great hints from this site, but the instructions for hint seem to be woefully incomplete.

After following the instructions and rebooting nothing happens.

I pasted the script into a plain text document and saved it as the instructions indicate. Since there was no /Library/Management folder I created one. I then made the script executable.

Double clicking the script brings up the Create Service dialog.

What am I missing here?



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: phillymjs on Sep 19, '08 08:44:24PM

More complete instructions are in another of my replies in this thread.

You don't launch it by double-clicking, you execute it in Terminal with root privileges, i.e. "sudo /Library/Management/initswupdater.sh". I could not duplicate what you were seeing on my test system.

When you run it it will immediately reboot the machine, so make sure you save any open files before you try it out. It was created with the intent of being either remotely executed on machines where the user is logged out, or manually kicked off by me when I'm rebuilding a machine-- so it's not particularly polite.

I have some plans to improve it, like having it pop up a dialog box in the GUI and let the user know what's about to happen and warn them to save their work, and give them the option to defer it. If they do defer it, I plan to make it nag them periodically (either just before a shutdown, or just after the next reboot) until they let it happen.

---
Need Mac support for a business in the Philadelphia, PA metro area? Contact me.



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: r0n on Sep 20, '08 01:02:19AM

While Installing a Tiger Mac the other week I thought about an automated SW update script being pretty useful, too. Gonna save this for the next time ;)



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: neuralstatic on Sep 22, '08 12:53:47PM
maybe i'm missing something, but you could also just do a

sudo softwareupdate -i -a; reboot to install all, reboot.

[ Reply to This | # ]

A script to install all required Software Updates
Authored by: rpaege on Sep 23, '08 11:53:00AM

Thank you neuralistic. In the absence of any kind of response from the OP, your tip (one I should have thought of myself) is excellent advice!



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: Echidna on Sep 24, '08 05:47:00AM

Ah, except that it doesn't solve the problem that the script above does. This will just do one iteration. Once you boot back up, there are probably other updates that were dependent upon the ones you just installed that are now active in Software Update.

The script above will repeatedly boot, install, and reboot... until there are no more new updates. Any time you update from a fresh install, there are about 3 or 4 iterations of the update, reboot processes... and this script saves you the headache of manually updating each time. :)



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: rpaege on Sep 23, '08 01:26:36PM

I get the error "reboot: Operation not permitted" after running the command.



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: rpaege on Sep 23, '08 01:55:40PM

Used:

sudo softwareupdate -i -a; sudo reboot


Seems to work OK.

Thanks for the tip!



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: slb on Sep 22, '08 04:59:16PM

Thanks, Philly!
Appreciate the help.
Nice thrash of Pitt yesterday :)

SB



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: Anonymous on Sep 23, '08 12:33:44PM
Rob, in light of so many confused users, you need to mark tips like this "advanced".

Either that, or do a little more editing before posting them.

[ Reply to This | # ]
A script to install all required Software Updates
Authored by: robg on Oct 04, '08 08:56:40PM

I read the hint and the comments in the script, and felt it was self-explanatory for those who would be tempted to use it -- users who are comfortable in Terminal. However, based on the comments, it appears I was mistaken; sorry about that. I've added a note telling folks to read the comments, where things are better explained.

-rob.



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: kielas on Oct 07, '08 12:28:12AM
I think I was able to execute the script, but now my login box is permanently entiteled "Software updates are currently being installed on this computer. Please do not attempt to log in until this message is gone." How do I remove what became a nag?

[ Reply to This | # ]
A script to install all required Software Updates
Authored by: phillymjs on Oct 09, '08 09:20:26AM
Run this command in Terminal:

sudo defaults delete /Library/Preferences/com.apple.loginwindow LoginwindowText

That is part of the cleanup the script does when there are no updates left, not sure why it didn't happen on your machine. I tested this extensively while developing it and never had that problem.

---
Need Mac support for a business in the Philadelphia, PA metro area? Contact me.

[ Reply to This | # ]

A script to install all required Software Updates
Authored by: gracoat on Oct 09, '08 10:14:32AM

It's an excellent script. Granted a bit on unix knowledge goes a long way in understanding what's going on with this.
I teach at a high school full of macs, and was looking for a nice way to update all the macs.

The system I have is such that my students cannot update the system, and thus the 'Software Update' window won't pop up for them. This means that I have to log in as an administrator to do so. Not only that, but my OD server has the software update server set up.

SO... This means that while the script works well, I have to poke at it to get it to look at my server instead up at Apple for updates.

Anyways... A quick explanation as to how this all works...

One user posted that they were concerned that writing over the default setting, leaving the message on your screen...
The first part of the first if statement looks for the existence of a file called /Users/Shared/.iniswupd_inprog
If it finds it it runs the updates.
When it's done updating the actual Software Update program actually runs again automatically... Behind the scenes in the console, Software update returns messages stating what it's found. This script looks for that using the "if [ `softwareupdate -l | wc -l` -le 3 ]"
Interestingly... the software update program when it finds nothing to update, it outputs 3 lines of code. Note in the text:

<b>`softwareupdate -l</b> --> this tells the computer to 'look at' the console output for anything softwareupdate. <b>| wc -l` -le 3]</b> -->the pipe then passes the info to the wc (word count) program with the modifier -l (<i>count lines instead of words</i>)

Lastly the program cleans up. The notable one is the delete from the loginwindow preference the Loginwindowtext line.

The rest of the script complex, but in plain english:

After looking to see if there's a file called .initswupd_inprog in the shared folder, and NOT finding one, it'll create one.
Then it adds the line of text to the login window screen.
Then it figures out which OS you're using so that it's able to give the right command as far as how to execute the update process.
Then it restarts! (wash-rinse-repeat) until there's no more updates.

**If you still have the text on your login window even if there's no more updates, then for whatever reason the defaults didn't reset. You can do so by stealing a line of text right from this script and typing it directly in the terminal.
You should do this as root user by the way.
Type the following in terminal:
defaults delete /Library/Preferences/com.apple.loginwindow LoginwindowText

Hope this makes things less muddy!
-Graham-



[ Reply to This | # ]
Fails if there are ignored updates
Authored by: tcj on Oct 10, '08 09:33:02AM

The script will fail (actually continue the rebooting cycle forever) if you re-install the system but keep users and network settings where you have ignored some updates. The script line:
if [ `softwareupdate -l | wc -l` -le 3 ]
returns "4" instead of "3" with ignored updates after all the other updates are installed. I don't know if just changing the 3 to a 4 in the script would work, or if something more is required.



[ Reply to This | # ]
Fails if there are ignored updates
Authored by: phillymjs on Nov 13, '08 07:26:33AM

I don't have any plans to add handling of that situation to the script, but just changing the linecount number it looks for probably wouldn't be enough... you'd probably want to also grep the results of softwareupdate for 'ignored' or whatever key word or phrase is returned when some updates are ignored.

---
Need Mac support for a business in the Philadelphia, PA metro area? Contact me.



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: macpretender on Oct 24, '08 08:14:10AM

I'm very new to creating shell scripts but am pleased that after reading through this script, I pretty much understand how it works and what it is doing. However, I cannot seem to get it to run.

I have created the Textedit document containing the script, saved it in my newly created /Library/Management folder as initswupdater.sh and ran chmod a+x initswupdater.sh from Terminal to make it executable. However, when I run the command: "sudo /Library/Management/initswupdater.sh", I get the message "No such file or directory".

I can browse to Macintosh HD/Library/Management and see that the initswupdater.sh file is located there. So I know it exists. Any ideas what I could be doing wrong?

Thanks for your help!!



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: phillymjs on Nov 13, '08 07:12:40AM

I did a little Googling and it looks to me like this issue is not because the script can't be found, i think it's more an issue with finding the shell. Do other shell scripts run?

Check the first line of the script and make sure you've got #!/bin/sh there, and look in your /bin directory to make sure sh is still in there.

If all else fails, try changing the script from #!/bin/sh to #!/bin/bash.

---
Need Mac support for a business in the Philadelphia, PA metro area? Contact me.



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: CyeZ on Jan 12, '09 07:23:58AM

This script initially didn't seem to work for me on a new Mac Pro. After some debugging I figured out the network cards weren't properly initialized yet by the time `softwareupdate -l` was being run.

Adding 'sleep 15' just above the pmset was enough to get things working as expected.



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: gabester on Apr 14, '09 12:29:17PM

I too was not having success getting this to run on a MBP 2.6Ghz w/SSD. It rebooted 2 or 3 times in 30 seconds then had a blank screen and glowing white power LED on the front. Adding 22 seconds above the pmset line did the trick as well.
g=



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: picoscope on Jun 19, '10 04:57:19PM

Hey there,

Thanks for posting this great hint. I'm in need of a bit of debugging though. Is this script still valid in Snow Leopard 10.6.4?

I ran the script, and my computer successfully rebooted with proper text in the login screen, but after 45 minutes it was clear no updates were happening. I logged in and confirmed via the softwareupdate log file. Any thoughts?

Thanks much,

p



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: picoscope on Jun 19, '10 05:33:41PM

Please ignore my last comment. It turns out that I was working on a computer that had not been pointed to our local update server - and thus was looking to the Apple server and taking far more time that I would normally expect of course.

Interesting: while I was logged in and trying to figure out what was happening, I tried to run Software Update manually from the Apple menu, and got the message "Software Updates are currently being installed by System Administrator". Very nice. That's actually what tipped me off that I'd missed something.

So yes, this script does appear to be Snow Leopard compatible!
Thanks again and cheers,
P



[ Reply to This | # ]
A script to install all required Software Updates
Authored by: picoscope on Jun 29, '10 02:04:39PM
Greetings, all. I've been working on honing this script to make it even more friendly and useful. I'm not nearly the script jockey many of you are, so please forgive me if I'm posting stuff here that can be done more easily and cleanly using other methods. In fact, if there are other methods for doing this better, please let me know!

I manage a small business network - about 30 clients. My goal was to have all clients grab their updates automatically from my local server at set times every night. Since many of our clients are frequently being used late at night, I also wanted to give users at least a little warning before hand.

Note that I did not, as phillymjs suggests, create an affordance for deferring - because I don't know how ;-)

Since many folks on this thread have asked for very basic instructions, I'm going to post as much information as I can to help as broad of an audience as I can. I'm still pretty much a self-taught newbie too, so I'll post in a way that would have helped me when I was first trying to figure this out.

First I'll give an overall description of how it all works, Then I'll give step by step instructions for how to implement this yourself. Finally, I'll post the actual code I used at the bottom of this post.

Here's how it all works.

The whole process is run by launchd - the launch daemon that is *the* core process of the Apple OS. Launchd is the process that loads first after the firmware process are done, and it launches all other aspects of the OS and everything else after that.

Launchd gets its marching orders via .plist files. These are located in several key locations in the directories created by Apple, and different locations are used to house specific types of .plist files. Generally, user-created .plist files are located at /Library/LaunchDaemons or /Library/LaunchAgents. Since we are loading applications that run once then disappear, the .plist files for these scripts will reside in LaunchAgents.

The .plist files I've created tell launchd to run two different programs at two different times, and to run them as root. One program launches a dialog box that warns users of the impending shutdown, the other runs the software update script itself.

For creating and editing .plist files, I use Property List Editor (an app that's available by installing the "Developer Tools" package found on the OS X Server Install DVD. I believe it's also available for free download from Apple). If you look at the code for these .plist files below, you'll see various options for times to load (set using a 24 hour clock), user, file path, etc. For example, I've set these plist files so that the software update shell script runs at 3AM and the warning dialog runs at 2:57AM. To change the times that these scripts run, open the file in Property List Editor and edit the values for the keys at "StartCalendarInterval/Item0/Hour and /Minute.

The .plist file "run.shutdown.warning.threeminute.plist" tells launchd to load a program called "shutdown.warning.threeminute.app" which it's expecting to find at /Library/Management.

The .plist file "run.auto.software.update.script.plist" tells launchd to load a program called "run.initswupdater.shell.app" which it's also expecting to find at /Library/Management.

The application "shutdown.warning.threeminute.app" was created using AppleScript and saved as a run-only application.If you paste the apple scripts below into a new script in AppleScript Utility and hit the "compile" button, you'll be able to see how it's put together. All this app does is open up a dialog box that says "This computer will shutdown automatically in 3 minutes for software updates. Please save any open files and log out now. The process should complete within a few minutes. Sorry for any inconvenience" - it also displays a warning icon and a single button to click labeled "Drat!". Clicking the button closes the window, but doesn't do anything else. You'll want to save this script in two formats: as an editable .scrpt file and as a run-only .app file (using Apple Script Utility/File/Save As).

The application "run.initswupdater.shell.app" loads the shell script initswupdater.sh, which it's expecting to find at /Library/Management. As with the other script, you'll want to save this script in two formats: as an editable .scrpt file and as a run-only .app file (using Apple Script Utility/File/Save As). I'll bet there's probably a way to run this shell script directly from launchd, but every method I've tried to accomplish this has failed, so I just put it together in the way I know works. If anyone can tell me how to do this directly from launched, I'd love to hear it!

The shell script initswupdater.sh can be edited using Xcode (also available as an optional install as above - and also I believe loaded into IS/Install Packages) - or with DashCode - which is available as a free download. This code and instructions for installing it on a client machine are described in detail in an earlier post to this thread.

To set up a client so that it automatically downloads the proper updates every night, do the following:

Before beginning, you will need a label maker, the root access password for the client, and a computer that has the Property List Editor program loaded.

1.First we need to tell the client where to look for updates. If you plan to continue getting updates directly from Apple, then you can skip this step. We'll use one of two different commands to accomplish this. One is for clients running OS 10.5.X and the other for clients running 10.6.X (for earlier OS check out this Apple Support Article: http://support.apple.com/kb/HT4069.

First login as root to the client. If you're not logged in as root, then preface the commands below with "sudo" - which runs these commands as root. You'll be prompted for the root password.

The command for Snow Leopard (10.6.x) clients will be:

defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL http://FQDN.of.your.swupd.server:8088/index-leopard-snowleopard.merged-1.sucatalog

The command for Leopard (10.5.x) clients will be:

defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL http://FQDN.of.your.swupd.server:8088/index-leopard.merged-1.sucatalog

Note that FQDN means "Fully Qualified Domain Name" - i.e. - the complete address of your server, e.g.: foo.example.com. Using that example, the code for a 10.6.X client would be

defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL http://foo.example.com:8088/index-leopard-snowleopard.merged-1.sucatalog

You could use the IP address instead of the FQDN if you like, though Apple prefers admins to use the FQDN.

2. Create the following files in a directory of your choice somewhere where you can access them and copy them to all of your clients:

"run.auto.software.update.script.plist" - use Property List editor, and paste the code for that .plist described below.

"run.shutdown.warning.threeminute.plist" - use Property List editor, and paste the code for that .plist described below.

"run.initswupdater.shell.scrpt - Use AppleScript Editor (found in /Applications/Utilities, paste the code for that script described below and save it as a run-only app. You might also want to save it as an editable script so you have a version you can customize.

"shutdown.warning.threeminute.scrpt" - Use AppleScript Editor (found in /Applications/Utilities, paste the code for that script described below and save it as a run-only app. You might also want to save it as an editable script so you have a version you can customize.

"initswupdater.sh" - follow the instructions from earlier in this thread to create this shell script. Note that I use DashCode (available as a free download) or XCode (available as an optional install on the Apple OS X Install DVD), which IMHO is a little easier and clearer than trying to edit these in a text editor. You can also save them as executables so you don't have to go mucking about with chmod (though many of us enjoy that kind of thing). ;-)

3. Choose a time for the client to run updates. Likely sometime between 2AM and 4AM (if you have more than a few clients, you'll likely want to stagger these so you don't have a bunch of clients hitting your server at once). Edit StartCalendarInterval keys in "run.auto.software.update.script.plist" and "run.shutdown.warning.threeminute.plist" such that the shutdown script runs at the chosen time and the warning script runs three minutes earlier.

4. Login as root to the client you wish to set up and copy those two .plist files to /Library/LaunchAgents. (or use the sudo mv command if you prefer the CLI)

5. On the client computer, create a folder in /Library called "Management".

6. "Copy "initswupdater.sh", "run.initswupdater.shell.app" and "shutdown.warning.threeminute.app" to the Management file you just created. Make sure you're copying the app files and not the editable scripts.

7. Restart the client OR open terminal (logged in as root) and run:


launchctl load /Library/LaunchAgents/run.shutdown.warning.threeminute.plist

and

launchctl load /Library/LaunchAgents/run.auto.software.update.script.plist

7. Using the label maker, make a label for the computer that says "Warning: This Computer will shut down automatically at [chosen:time] for software updates. You will get a three minute warning notice before this happens". Place this label in a prominent location - e.g. along the top of the case right above the screen (but don't cover over the iSight camera).

8. Login to the client at your chosen time to verify that all scripts are running as expected. What I did when testing these was to edit the .plist files to create times just a few minutes in the future, then watched as they ran, then reset them with the proper times.

Here's the code for the various files mentioned above:

run.auto.software.update.plist:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>UserName</key>
	<string>root</string>
	<key>Label</key>
	<string>run.auto.softwareupdate.script</string>
	<key>ProgramArguments</key>
	<array>
		<string>open</string>
		<string>/Library/Management/run.initswupdater.shell.app</string>
	</array>
	<key>RunAtLoad</key>
	<false/>
	<key>StartCalendarInterval</key>
	<array>
		<dict>
			<key>Hour</key>
			<integer>3</integer>
			<key>Minute</key>
			<integer>0</integer>
		</dict>
	</array>
</dict>
</plist>

run.shutdown.warning.plist:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>run.shutdown.threeminute.script</string>
	<key>ProgramArguments</key>
	<array>
		<string>open</string>
		<string>/Library/Management/shutdown.warning.threeminute.app</string>
	</array>
	<key>RunAtLoad</key>
	<false/>
	<key>StartCalendarInterval</key>
	<array>
		<dict>
			<key>Hour</key>
			<integer>2</integer>
			<key>Minute</key>
			<integer>57</integer>
		</dict>
	</array>
</dict>
</plist>

run.initswupdater.shell.scrpt:


do shell script "/Library/Management/initswupdater.sh"

shutdown.warning.threeminute.scrpt


display dialog "This computer will shutdown automatically in 3 minutes for software updates. Please save any open files and log out now. The process should complete within a few minutes. Sorry for any inconvenience" buttons {"Drat!"} default button 1 with icon stop

I hope folks find this helpful!

Cheers,

Picoscope

[ Reply to This | # ]