Shutdown on press of the power button..


Forum: Other Help Topics
Topic: Shutdown on press of the power button..
started by: eeffoC

Posted by eeffoC on Jan. 13 2007,20:18
Hi!

I am wondering if there is an easy way to make my DSL system react on my power button.
I would like to perform a system shutdown if the button is pressed shortly.

Any ideas how to solve this?

Thanks in advance!

Posted by ^thehatsrule^ on Jan. 13 2007,22:13
/etc/inittab , acpi , apm keywords might help you out...
Posted by Juanito on Jan. 15 2007,03:13
If your system is acpi compliant, you can "apt-get install acpid".

The acpid daemon will detect "power button events" and run a script of your making. If you put the following in the script, you should get a shutdown when you press the button briefly:

exitcheck.sh shutdown (or reboot)

Posted by eeffoC on Jan. 16 2007,17:35
Hi Juanito,

that sounds like a clean and straight way for me, thanks a lot for your advice!

Today I finally found some time to try it.. here is what I have done (im working with a frugal system with cf card on a quite modern computer):

- changed the bootoption "noacpi" into "acpi=force"
- apt-get install acpi
- changed powerbtn.sh as required
- put powerbtn.sh and events/powerbtn in filetool.lst

I tested my powerbutton.sh script by executing it manually and it works fine. Also I can let the acpi commands show me the temperature of my system - but still it doesnt react on my powerbutton.
Also I cant find a logfile on (/ramdisk)/var/logs/

Any further ideas on this problem? Maybe I forgot something?

Thanks a lot in advance,

Jan

Posted by roberts on Jan. 16 2007,17:45
I don't start syslogd by default on live CD or frugal type installations.
But for debuging it is nice to start and then check /var/log/messages.

sudo syslogd

It there!

Posted by eeffoC on Jan. 16 2007,20:07
Thanks a lot for your suggestion Roberts!

But, shame on my head, I just hadnt the demon running while looking for the log file (didnt realise at first that it was gone after restart - sorry) :-(
I had to start the demon manually in bootlocal.sh.

Now I do have a log file in /var/logs but it still doesnt recognise any powerbutton interactions.

When I type something like acpid -{anycommand} it tells me:

acpid: can't open /proc/acpi/event: Device or ressource busy

Maybe thats my problem? How am I supposed to work around this?


*Edit*
Another annoying thing is that I am now prompted everytime I boot (when the acpid.deb is installed) whether I want to overwrite the modified powerbtn.sh or not. I cannot find the file to modify this - any experiences with this?

Posted by Juanito on Jan. 17 2007,03:39
The acpi log may give you some clues and you could also check if the button module is loaded.

Another thing to try could be to make your own acpid.dsl/.unc which include the powerbtn files - this would avoid the overwrite yes/no prompt.

Posted by eeffoC on Jan. 20 2007,23:05
I ve been trying this on several kinds of installations and machines now...

after apt-get install acpid the daemon is loaded as expected

the acpi logfile shows:
[Sun Jan 21 00:02:07 2007] starting up
[Sun Jan 21 00:02:07 2007] 1 rule loaded
(..but never more than that)

and typing "acpid" as root i get the message
acpid: can't open /proc/acpi/event: Device or ressource busy

Its the same on every installation and on every machine. I guess thats the reason why acpid is not working correctly but I have no clue how to fix it.

Someone out there who can help?

Posted by Juanito on Jan. 21 2007,14:41
This post might help:

< http://damnsmalllinux.org/cgi-bin....29;st=5 >

Posted by eeffoC on Jan. 21 2007,22:10
Thanks a lot Juanito. I already knew your thread and now have to admit that it of course perfectly works like you describe!!

I used lsof to check wich process is working with /proc/acpi/events and the answer was: acpid...

Even more confused I finally pressed all other buttons on my computer (like PRG, Reset and Sleep) and, what a wonder, it performed a nice shutdown in press of sleep (instead of power, hell knows why).

several days of research just to find out that the answer is so stupid... i love it

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.