diff mbox

[OpenWrt-Devel] base-files: rework reset button script to indicate factory reset

Message ID 1439251044-15693-1-git-send-email-zajec5@gmail.com
State Accepted
Headers show

Commit Message

Rafał Miłecki Aug. 10, 2015, 11:57 p.m. UTC
With this change we let user know 5 seconds have passed and reset button
can be released (to trigger factory reset)

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 package/base-files/files/etc/rc.button/reset | 35 +++++++++++++++++-----------
 1 file changed, 21 insertions(+), 14 deletions(-)

Comments

Bastian Bittorf Aug. 12, 2015, 7:32 a.m. UTC | #1
* Rafał Miłecki <zajec5@gmail.com> [11.08.2015 21:01]:

is there a special reason, that you are using

exec /sbin/poweroff

instead of just

/sbin/poweroff

bye, bastian
Rafał Miłecki Aug. 12, 2015, 12:48 p.m. UTC | #2
On 12 August 2015 at 09:32, Bastian Bittorf <bittorf@bluebottle.com> wrote:
> * Rafał Miłecki <zajec5@gmail.com> [11.08.2015 21:01]:
>
> is there a special reason, that you are using
>
> exec /sbin/poweroff
>
> instead of just
>
> /sbin/poweroff

I think you're commenting on a wrong patch.
Bastian Bittorf Aug. 12, 2015, 1:19 p.m. UTC | #3
* Rafał Miłecki <zajec5@gmail.com> [12.08.2015 15:10]:
> I think you're commenting on a wrong patch.

sorry, yes - the comment applies to:
a643de25/r40909 and i just stumpled upon this
while reading the affected sources of your patch.

@stefan: why is this 'exec' needed?

bye, bastian
Stefan Hellermann Aug. 15, 2015, 4:30 p.m. UTC | #4
hi,

it's not needed, you can remove it.

Stefan

2015-08-12 15:19 GMT+02:00 Bastian Bittorf <bittorf@bluebottle.com>:

> * Rafał Miłecki <zajec5@gmail.com> [12.08.2015 15:10]:
> > I think you're commenting on a wrong patch.
>
> sorry, yes - the comment applies to:
> a643de25/r40909 and i just stumpled upon this
> while reading the affected sources of your patch.
>
> @stefan: why is this 'exec' needed?
>
> bye, bastian
>
diff mbox

Patch

diff --git a/package/base-files/files/etc/rc.button/reset b/package/base-files/files/etc/rc.button/reset
index 3e24146..c6dc7cf 100755
--- a/package/base-files/files/etc/rc.button/reset
+++ b/package/base-files/files/etc/rc.button/reset
@@ -1,20 +1,27 @@ 
 #!/bin/sh
 
-[ "${ACTION}" = "released" ] || exit 0
-
 . /lib/functions.sh
 
-logger "$BUTTON pressed for $SEEN seconds"
-
-if [ "$SEEN" -lt 1 ]
-then
-	echo "REBOOT" > /dev/console
-	sync
-	reboot
-elif [ "$SEEN" -gt 5 ]
-then
-	echo "FACTORY RESET" > /dev/console
-	jffs2reset -y && reboot &
-fi
+case "$ACTION" in
+pressed)
+	return 5
+;;
+timeout)
+	. /etc/diag.sh
+	set_state failsafe
+;;
+released)
+	if [ "$SEEN" -lt 1 ]
+	then
+		echo "REBOOT" > /dev/console
+		sync
+		reboot
+	elif [ "$SEEN" -gt 5 ]
+	then
+		echo "FACTORY RESET" > /dev/console
+		jffs2reset -y && reboot &
+	fi
+;;
+esac
 
 return 0