[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: FW: UPS question about /etc/rc0.d/S90halt and /etc/init.d/ups-mon itor (woody)



On Mon, 2003-05-12 at 23:54, Roland Gerlach wrote:
> I have an APC Smart-UPS and run apcupsd 3.8.5 and I have a question about
> the woody shutdown sequence. 
> 
> The last step in a change to run level 0 calls S90halt:
> 
> ==> /etc/rc0.d/S90halt <==
> #! /bin/sh
> #
> # halt		Execute the halt command.
> #
> # Version:      @(#)halt  2.84-2  07-Jan-2002  miquels@cistron.nl
> #
> 
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
> 
> # See if we need to cut the power.
> if [ -x /etc/init.d/ups-monitor ]
> then
> 	/etc/init.d/ups-monitor poweroff
> fi
> 
> # Don't shut down drives if we're using RAID.
> hddown="-h"
> if grep -qs '^md.*active' /proc/mdstat
> then
> 	hddown=""
> fi
> 
> halt -d -f -i -p $hddown
> 
> : exit 0
> === eof ===
> 
> So the first thing S90halt does is to call /etc/init.d/ups-monitor (which is
> provided by apcupsd):
> 
> ==> /etc/init.d/ups-monitor <==
> #!/bin/sh
> # apcupsd halt script
> # by Martin Mitchell <martin@debian.org>
> # modifications by Gordon Morehouse <spambox@evernex.com> April 2001
> 
> case "$1" in
> 	poweroff | killpower)
> 	if [ -f /etc/apcupsd/powerfail ]; then
> 		echo ""
> 		echo -n "apcupsd: Ordering UPS to kill power... "
> 		/etc/apcupsd/apccontrol killpower
> 		echo "done."	
> 		echo ""
> 		echo "Please ensure the UPS has powered off before
> rebooting."
> 		echo "Otherwise, the UPS may cut the power during the
> reboot!"
> 		echo ""
> 		sleep 2d
> 	fi
> 	;;
> 
> 	*)
> 	;;
> esac
> 
> exit 0
> === eof ===
> 
> My concern is that if there was a power failure, then the file
> /etc/apcupsd/powerfail would exist causing ups-monitor to call
> /etc/apcupsd/apccontrol killpower.  The ups-monitor script would then sleep
> for 2 days.  This will prevent the rest of S90halt from running.  Therefore
> the final halt command would never be run.
> 
> I realise that the system would be turned off after the "shutdown grace
> delay" in the ups but wouldn't it be nicer to the system if the "halt .. -p"
> command at the end of S90halt was run so that the PC powers itself off
> rather than suffer a power failure?
> 
> Cheers,
> Roland.
> --
> Tell me and I'll forget, show me and I may remember,
> involve me and I'll understand - Chinese Proverb.

Properly, the system shouldn't return from calling
/etc/apcupsd/apccontrol killpower (which should be --killpower) as it is
supposed to switch off the UPS - if it doesn't, it tosses this message
on the screen to say that it couldn't shut off the UPS. My reading of
the scripts (mind you, I am digging through mine, but I have apcupsd
3.10.5, as I have a USB cabled UPS) are that this is supposed to be run
as part of the winding down of shutdown, ensuring that some device isn't
still on and draining the UPS battery to total exhaustion, rather than
using APM which only powers off the cpu/memory/drives. In other words,
S90halt isn't good enough in this situation - you want the UPS power
feed killed.

The sleep 2d is to ensure that the message to shut off the UPS is seen
if the system has a console if the computer couldn't do it on its own. 
-- 
Mark L. Kahnt, FLMI/M, ALHC, HIA, AIAA, ACS, MHP
ML Kahnt New Markets Consulting
Tel: (613) 531-8684 / (613) 539-0935
Email: kahnt@hosehead.dyndns.org

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: