OpenWrt Forum Archive

Topic: wl-hdd reset button

The content of this topic has been archived on 29 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,
I'm running WhiteRussian 0.9 on an ASUS WL-HDD.
I would like to use the reset button to trigger a script as described here:  http://forum.openwrt.org/viewtopic.php?id=8745

I created a the following test script; but nothing happens when the button is pressed.

cat /etc/hotplug.d/button/script

#!/bin/sh
echo $BUTTON $ACTION $SEEN $SHELL

furthermore; the BUTTON ACTION and SEEN environment variables don't seem to exist.

I can see the button's affect in /dev/gpio/in, and /proc/interrupts.

is this relevant or wrong? is it set with nvram?
cat /proc/diag/gpiomask
0x0000

I am new to OpenWrt, so please forgive me if I am missing something obvious.

#!/bin/sh                                                                       
logger "BUTTON=$BUTTON ACTION=$ACTION SEEN=$SEEN"

After pressing the button:

# logread
Apr 21 20:23:26 (none) user.notice root: BUTTON=reset ACTION=pressed SEEN=15954
Apr 21 20:23:28 (none) user.notice root: BUTTON=reset ACTION=released SEEN=1

Hi Riverman

are you sure that the diag module is active? What do you get when you enter
"dmesg |grep diag " ?

/T

Hi Timo

dmesg | grep diag
diag: Detected 'ASUS WL-HDD'

RR

Thanks marcZ,

#!/bin/sh
logger "BUTTON=$BUTTON ACTION=$ACTION SEEN=$SEEN"
echo  "BUTTON=$BUTTON ACTION=$ACTION SEEN=$SEEN"

Jan  1 00:57:29 (none) user.notice root: BUTTON=reset ACTION=pressed SEEN=257
Jan  1 00:57:30 (none) user.notice root: BUTTON=reset ACTION=released SEEN=0

but no output from "echo".  There is when script is run manually, but no sign of the variables.

This seems really strange to me.
what am I missing?

Riverman

Thanks all,

It seems it was working all along.
What threw me is that the scripts only echo to the screen when I run it from the command line, but not when executed from the button. I would be grateful if someone could explain to me why this is the case.

regards,
riverman

riverman wrote:

Thanks all,

It seems it was working all along.
What threw me is that the scripts only echo to the screen when I run it from the command line, but not when executed from the button. I would be grateful if someone could explain to me why this is the case.

regards,
riverman

Probably because it isn't launched with a controlling terminal. echo will just print to stdout, but with no controlling terminal it doesn't get sent to the console or any pty you may be logged in with.

I don't understand where you expect your echo to go.  If you run your script from the terminal it goes to /fd/1 which is linked to a pts (look at /proc/$$/fd/1), it is what you call your screen

But when your script is run by /sbin/hotplug you have no pts,  and I don't understand on which screen you expect the output to go? On a desktop you allocate tty in initd and an old habit no longer in use was to redirect kernel messages to an unused tty. But your wl-hdd has not this big attached console, so the only place is syslog (that you can send to a memory buffer, a file, a tcp or udp socket).

Your script inherit its output from /sbin/hotplug, that probably inherit it from init. (I'm not sure, hotplug has changed since kernel 2.6 and is now triggered by udev, I don't remenber exactly the kernel 2.4 way) of course you can change /sbin/hotplug to log the standard output and error of the scripts or to redirect it to a file, or socket.

But it is simpler to write directly to syslog, with logger.

Thanks for the explanations; it is much clearer now.

The discussion might have continued from here.