Shutdown Script?

Rick Stevens rstevens at vitalstream.com
Mon Aug 15 16:23:56 UTC 2005


Mark McCulligh wrote:
> Hi Group,
> 
> I have just setup nut on my computer to manage my UPS.  I have to add a 
> couple lines of code to my shutdown script to power off my UPS.  Is 
> there a master shutdown script I should add these lines too or create a 
> new script and add it to init.d?
> 
> I don't want to get this wrong and turn of the UPS at the wrong time.

The system runs /etc/rc.d/init.d/halt as the last thing, so any commands
really belong there.  If you examine that script, you'll see that it
tries to do some UPS management itself, based on the presence of several
files (/etc/ups/upsmon.conf, /etc/killpower and /etc/sysconfig/ups) and
uses variables set in /etc/sysconfig/ups.

If $SERVER is "yes" AND "$MODEL" is "upsdrvctl", then it runs upsdrvctl
and passes it the "shutdown" option:

	/sbin/upsdrvctl shutdown

If "$SERVER" is "yes", "$MODEL" is not null AND not equal to "NONE" AND
"$DEVICE" is not null, then it runs the program given in "$MODEL"
against "$DEVICE" and hands it the options specified in "$OPTIONS_HALT"
thusly:

	$MODEL $OPTIONS_HALT -k $DEVICE

Examine the script starting at around line 221 or so (in the FC4
version) to see what I'm talking about.  If none of this suits your
needs, add what you need somewhere in that section of the script or call
one of your own:

	if [ "$SERVER" = "yes" -a "$MODEL" = "yourdevicename" ]; then
	    /usr/local/your-shutdown-script
	fi

Hope that helps.
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-                       When in doubt, mumble.                       -
----------------------------------------------------------------------




More information about the Redhat-install-list mailing list