OS X and UPS?
September 26, 2008 2:59 PM   Subscribe

OS X and a APC UPS - clever solutions?

I have this UPS and I would like to configure my 10.5 machine to handle interruptions intelligently. The UPS has a USB out, so I assuming it sends signals that I can work with. I'd like the computer to eject the two Firewire drives whenever it loses power, etc. I'd like more options (I'm thinking scripts as opposed to a GUI), if possible.

Anyone have any clever OS X UPS solutions?
posted by xmutex to Computers & Internet (6 answers total) 2 users marked this as a favorite
 
Well, if you use APC PowerChute Personal Edition for Macintosh, you can have it optionally call a script before it shuts down. You could put whatever you wanted in that script. See the readme for details.
posted by SNACKeR at 3:17 PM on September 26, 2008


Mac OS X has built-in software that will recognize the UPS, which will then show up in the Energy Saver control panel. (The UPS also probably came with software, but you don't need it.) It doesn't do anything that fancy, it just lets you automatically shut down when a certain amount or percentage of runtime is left. You can also have it sleep the screen and disks faster when it's on the UPS, of course. If you need more functionality, it looks like you are going to be doing the coding yourself. I found a couple of shareware things on MacUpdate that might have helped if their Web sites had been responding.
posted by kindall at 3:24 PM on September 26, 2008


Oh, I must have missed the script option in PowerChute. Excellent catch.
posted by kindall at 3:27 PM on September 26, 2008


When I talked to APC support a couple of weeks ago, PowerChute isn't yet supported on OS X 10.5 Intel machines. Equinux has a product "APC Tracker" that may be of some use to you, if you don't get anywhere with APC's own software.
posted by crysflame at 3:33 PM on September 26, 2008


Seconding APC PowerChute PE. You can add whatever other shutdown stuff you need, in addition to timing info:

As well as support for serial connections, PowerChute has the ability to trigger scripts prior
to shutdown. PowerChute Personal Edition looks for an executable file with the following
pathname:

/etc/comapcpcpe/PowerChute.pre_shutdown

This file is optional, and is not present by default. The file and directory can only be created
by a user with root access.

posted by Blazecock Pileon at 3:34 PM on September 26, 2008


You can do this with just scripting and the Energy Saver system preference panel, no 3rd party software necessary, by writing a Mac OS X StartupItem that calls drutil.
  1. Use the Energy Saver system preference panel to configure the Mac to shutdown automatically when UPS failure is imminent.
  2. Create a directory called "EjectDrive".
  3. Create a text file named "EjectDrive" in the "EjectDrive" folder.
  4. This text file should have the following contents (note that this example ejects the default drive, you might have to adjust the parameters to drutil to specify the particular drive you wish to eject):
    #!/bin/sh		### Eject drive on shutdown##. /etc/rc.commonStartService (){	# do nothing	return 0}StopService (){	ConsoleMessage "Ejecting drive"	/usr/bin/drutil tray eject	return 0}RestartService (){	StopService	StartService	return 0}RunService "$1"
  5. Create a text file named "StartupParameters.plist" in the "EjectDrive" folder.
  6. This text file should have the following contents:
    {	Description     = "Eject default drive at stutdown.";	Provides        = ("EjectDrive");	Requires        = ();	Uses            = ();	OrderPreference = "None";}
  7. Copy the "EjectDrive" folder to "/Library/StartupItems/".
  8. Set the permissions in the EjectDrive folder as mentioned in the Startup Item Permissions section of the StartupItem document. If you wish, you can omit this step. If you do, your Mac will complain on the next boot that a startup item has invalid permissions and offer you the options of having the OS set the permissions of these files for you.
  9. Restart your computer.
If everything is working OK you should see a console message "com.apple.SystemStarter[XX]: Ejecting drive" in the system log if you check it following a shutdown.
posted by RichardP at 5:12 PM on September 26, 2008


« Older Lordy, lordy, I'm hittin' 40!   |   Web designers' top 5 Newer »
This thread is closed to new comments.