Easy Button Control (UCI)

The OpenWRT port for the MBox/Clones has the hotplug package installed by default.

Good use of this package can be made by using it to control the hardware buttons on the front of the NASBOX.
On the OpenWRT site there is a script called "Atheros' 00-button + UCI" that integrates button control into the UCI system.

An example of how to use it follows.

Step 1:
Log into the NAS box with a SSH program like WINSCP.

Step 2:
Create /etc/hotplug.d/button/00-button with your favorite editor, then paste the following code:

Quellcode

Second Text file is called SCRIPT_Reboot.txt and holds the following code:

Quellcode

1

reboot

With these system modifications in place:
1) The top button will shutdown the OS of the NASBOX so that it is safe to turn Off the power (also turns Off the power LED to let you know).
2) The bottom button will reboot the OS of the NASBOX.
3) Most importantly you can now issue UCI commands to change the behaviour of these buttons.

button is the name as the button, action is the event (two values: pressed and released), handler contains the command line to be run when the event is detected (can be a script as well).
Issuing the UCI commands adds entries in the system configuration file like the ones we added manually at Step 3 (to get things set up quickly!).
Try to generate some entries with the UCI commands yourself and see how easy it is to generate these entries in the system configuration file. Soon you will be able to redefine the behaviour of these buttons to suit your own needs.

Finally, see also the Button Script For MBox posted here for a simple way to achieve shutdown and reboot functions for the hardware buttons.