General NAS-Central Forums

Welcome to the NAS community
It is currently Mon Nov 20, 2017 11:07 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: daemon for power button
PostPosted: Mon Oct 27, 2008 11:12 pm 
Offline

Joined: Thu Jun 12, 2008 10:59 pm
Posts: 8
Location: Kladno, Czech Republic
EDIT: I've updated the daemon. It now supports configuration file and has nice manual page. It's available on http://malat.biz/view/Projects/ButtonDaemon

OLD (now obsolete) POST FOLLOWS:
I've written simple daemon for handling powerbutton events. It's possible to define intervals and if button is pressed for the time from defined interval, the asociated command is executed.

Usage
1. Create buttom device
Code:
mknod /dev/pwrbtn c 13 64

2. Edit buttond.c:
Customize this structure:
Code:
const struct action_s actions[] = {
        {0., 1.5, "shutdown -h now"}, /* If the power button is pressed for any time from interval (0, 1.5) seconds, "shutdown -h now" will by executed */
        {4., 8.,  "ifconfig eth0 192.168.1.1 netmask 255.255.255.0"}
};

3. Compile
Code:
gcc -Os -Wall -o buttond buttond.c
strip buttond

4. Run it
Code:
./buttond -d /dev/pwrbtn


This is probably usefull only if you are running nonoriginal distribution like me. Tested with vanilla kenel-2.6.28-rc1 on debian lenny ;-)


Last edited by petris on Wed Oct 07, 2009 7:38 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sat Nov 01, 2008 9:46 pm 
Offline

Joined: Sat May 17, 2008 2:57 pm
Posts: 32
Could you tell me, does your EDv2 turn off completely after "shutdown -h now" or "poweroff"? In my case, HDDs turn off, but FAN works and LED doesn't stop lighting.

I have the same configuration as you, except I have EBD.


Top
 Profile  
 
PostPosted: Sat Nov 01, 2008 11:18 pm 
Offline

Joined: Thu May 08, 2008 11:23 am
Posts: 112
Location: near Toulouse, France
kosmaty wrote:
Could you tell me, does your EDv2 turn off completely after "shutdown -h now" or "poweroff"? In my case, HDDs turn off, but FAN works and LED doesn't stop lighting.

I am afraid that I have not had time to try petris' daemon yet.
However I am pretty sure that these commands will cause the EDmini v2 (and the EBD) to reboot rather than to power-off :(
We spoke about this in this EBD topic: viewtopic.php?f=151&t=61&st=0&sk=t&sd=a&start=15#p951
The procedure described there works with the stock kernel but I don't think that it will work with the mainline kernel.
The actual power-off is done by U-Boot and to cause it a special flag has to be written in the I2C EEPROM.
Unfortunately I don't think that the I2C EEPROM is currently detected in the mainline kernel :(


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group