Mailing List Archive


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

Re: [tlug] Linux init 0 by powerbutton



On Thu, 22 Jul 2004 06:34:08 +0200, patrick.niessen@example.com wrote:

> I am looking to create a Home Server which is easy to use: press power
> button to provide network share and ftp, press again to orderly shutdown
> the server (=init 0 + powerdown).  I already have a Windy box type pc,
> which should be runnning ideally headless without keyboard and mouse.

The BIOS will probably require that you have a graphics card even if you
don't attach a screen to it. I had a cheap old PCI card doing nothing in
particular so I used that.

You might find a keyboard handy even if you don't use it. It has got me out
of a fix more than once here.

Having a keyboard and at least a graphics adaptor makes it relatively
painless to troubleshoot the sucker if the network doesn't work for some
reason.

> What kind of requirements are there to consider - which kernel options
> should be compiled in and is there a shutdown daemon that needs to be
> running?

You'll want a machine which is recent enough to have a not too buggy
implementation of ACPI. About 1999 vintage or later will do the trick. If
the machine is closer to that vintage than to present day technology you
might need to add "acpi=force" to the kernel command line. Make sure your
BIOS is set with ACPI support and so that the machine doesn't power off
immediately when you hit the power button (usually it takes 4 seconds
pressing on it).

You'll then need to add ACPI support to the kernel (but not APM, they're
mutually exclusive), with support for the power button. This will generate
an ACPI event whenever the power button is pressed, in turn generating a
line in the pseudo file /proc/acpi/event.

Finally, you'll need acpid (supplied with most distros) which reads events
turning up in /proc/acpi/event and which runs commands based on the type of
event which happened and on a configuration file in /etc/acpi/events.

I have this setup here:

/etc/acpi/events/default:
# This is the ACPID default configuration, it takes all
# events and passes them to /etc/acpi/default.sh for further
# processing.

# event keeps a regular expression matching the event. To get
# power events only, just use something like "event=button power.*"
# to catch it.
# action keeps the command to be executed after an event occurs
# In case of the power event above, your entry may look this way:
#event=button power.*
#action=/sbin/init 0

# Optionally you can specify the placeholder %e. It will pass
# through the whole kernel event message to the program you've
# specified.

event=.*
action=/etc/acpi/acpi_handler.sh %e


/etc/acpi/acpi_handler.sh:
#!/bin/sh
# Default acpi script that takes an entry for all actions

set $*

case "$1" in
	button/power)
		case "$2" in
			PWRF)	/sbin/poweroff
				;;
			*)	logger "ACPI group $1 / action $2 is not defined"
				;;
		esac
		;;

	*)
		logger "ACPI group $1 / action $2 is not defined"
		;;
esac

-- 
G. Stewart   --   gstewart@example.com -- gstewart@example.com
Registered Linux user #284683 (Slackware 9.0, Linux 2.6.7-em8300)
--------------------------------------------------------------
A grammarian's life is always intense.

Attachment: pgp00053.pgp
Description: PGP signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links