From: Jolly Roger on
On 2006-09-09 10:03:05 -0500, "zit" <ttrtilley(a)gmail.com> said:

> JollyRoger wrote:
>> Most Wintel PCs allow you to set whether or not they power off when you shut
>> down the operating system. Macs don't appear to have such an option.
>
> Macs *appear* to have such an option, "sudo shutdown -h"
> but it is ignored and "sudo shutdown -p"
> is done instead, so they don't really have it :)

Exactly. A deeper understanding of the Mac-specific shutdown process
is called for here!

-JR

From: Jeffrey Goldberg on
Malcolm wrote:

> Have the Mac shutdown all the applications, and send the shutdown
> command to the UPS, but not shut itself down. The delay before the UPS
> shuts down will give plenty of time for the disk caches to be flushed.

Hmm. Maybe just going to init state 1 would be sufficient. That seems
like a reasonable approximation.

-j


--
Jeffrey Goldberg http://www.goldmark.org/jeff/
I rarely read top-posted, over-quoted or HTML posts
My Reply-To address is valid.
From: Jolly Roger on
On 2006-09-09 17:50:46 -0500, Jeffrey Goldberg <nobody(a)goldmark.org> said:

> Malcolm wrote:
>
>> Have the Mac shutdown all the applications, and send the shutdown
>> command to the UPS, but not shut itself down. The delay before the UPS
>> shuts down will give plenty of time for the disk caches to be flushed.
>
> Hmm. Maybe just going to init state 1 would be sufficient. That seems
> like a reasonable approximation.
>
> -j

The way they handle this situation on Linux systems (with the apcupsd
UPS daemon, anyway) is they insert code that sends a 'killpower'
command to the UPS at a certain point during the shutdown into the rc
shutdown script (/etc/init.d/halt, for instance). The code also makes
sure that the shutdown command is not issued with the -p switch. The
UPS responds to the 'killpower' command by (up to 120 seconds later)
cutting power to the computer.

The problem is, on Mac OS X, the /etc/shutdown utility *always* does a
-p (power off), regardless of whether or not the -p switch is used.

Anyway, on Mac OS X, the rc shutdown script is /etc/rc.shutdown, and it
looks like this (factory default):

---
#!/bin/sh
# Copyright 1997-2004 Apple Computer, Inc.

.. /etc/rc.common

if [ -f /etc/rc.shutdown.local ]; then
sh /etc/rc.shutdown.local
fi

SystemStarter stop

kill -TERM 1

exit 0

---

I believe the 'kill -TERM 1' command tells /sbin/launchd to die, which
(eventually) results in a power down.

At any rate, the code that apcupsd normally inserts into the rc
shutdown script (on Linux systems) is similar to this:

---
# See if this is a powerfail situation (apcupsd).
if [ -f /etc/apcupsd/powerfail ]; then
echo
echo "APCUPSD will now power off the UPS"
echo
/etc/apcupsd/apccontrol killpower
echo
echo "Please ensure that the UPS has powered off before rebooting"
echo "Otherwise, the UPS may cut the power during the reboot!!!"
fi
---

They insert this code just before the final halt of the system (where
/sbin/halt is called).

The trick for us Mac users is to figure out where to insert that code
such that it is executed before power off. I wonder if a modification
to launchd rules is in order?

--
-JR

From: Jolly Roger on
On 2006-09-10 11:39:08 -0500, Jolly Roger <jollyroger(a)null.org> said:

> On 2006-09-09 17:50:46 -0500, Jeffrey Goldberg <nobody(a)goldmark.org> said:
>
>> Malcolm wrote:
>>
>>> Have the Mac shutdown all the applications, and send the shutdown
>>> command to the UPS, but not shut itself down. The delay before the UPS
>>> shuts down will give plenty of time for the disk caches to be flushed.
>>
>> Hmm. Maybe just going to init state 1 would be sufficient. That seems
>> like a reasonable approximation.
>>
>> -j
>
> The way they handle this situation on Linux systems (with the apcupsd
> UPS daemon, anyway) is they insert code that sends a 'killpower'
> command to the UPS at a certain point during the shutdown into the rc
> shutdown script (/etc/init.d/halt, for instance). The code also makes
> sure that the shutdown command is not issued with the -p switch. The
> UPS responds to the 'killpower' command by (up to 120 seconds later)
> cutting power to the computer.
>
> The problem is, on Mac OS X, the /etc/shutdown utility *always* does a
> -p (power off), regardless of whether or not the -p switch is used.
>
> Anyway, on Mac OS X, the rc shutdown script is /etc/rc.shutdown, and it
> looks like this (factory default):
>
> ---
> #!/bin/sh
> # Copyright 1997-2004 Apple Computer, Inc.
>
> . /etc/rc.common
>
> if [ -f /etc/rc.shutdown.local ]; then
> sh /etc/rc.shutdown.local
> fi
>
> SystemStarter stop
>
> kill -TERM 1
>
> exit 0
>
> ---
>
> I believe the 'kill -TERM 1' command tells /sbin/launchd to die, which
> (eventually) results in a power down.
>
> At any rate, the code that apcupsd normally inserts into the rc
> shutdown script (on Linux systems) is similar to this:
>
> ---
> # See if this is a powerfail situation (apcupsd).
> if [ -f /etc/apcupsd/powerfail ]; then
> echo
> echo "APCUPSD will now power off the UPS"
> echo
> /etc/apcupsd/apccontrol killpower
> echo
> echo "Please ensure that the UPS has powered off before
> rebooting" echo "Otherwise, the UPS may cut the power during the
> reboot!!!" fi
> ---
>
> They insert this code just before the final halt of the system (where
> /sbin/halt is called).
>
> The trick for us Mac users is to figure out where to insert that code
> such that it is executed before power off. I wonder if a modification
> to launchd rules is in order?

The real question I have is: How, specifically, does the Mac determine
whether or not a clean shutdown happened on power up?

--
-JR

From: Malcolm on
>
> The real question I have is: How, specifically, does the Mac determine
> whether or not a clean shutdown happened on power up?
If it was a clean shutdown the boot disk will be dismounted.

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Training SpamAssassin
Next: Recovered Files Curious About ?