base-files: fix off-by-one in counting seconds for factory reset
[openwrt/staging/chunkeey.git] / package / base-files / files / etc / rc.button / reset
1 #!/bin/sh
2
3 . /lib/functions.sh
4
5 OVERLAY="$( grep ' /overlay ' /proc/mounts )"
6
7 case "$ACTION" in
8 pressed)
9 [ -z "$OVERLAY" ] && return 0
10
11 return 5
12 ;;
13 timeout)
14 . /etc/diag.sh
15 set_state failsafe
16 ;;
17 released)
18 if [ "$SEEN" -lt 1 ]
19 then
20 echo "REBOOT" > /dev/console
21 sync
22 reboot
23 elif [ "$SEEN" -ge 5 -a -n "$OVERLAY" ]
24 then
25 echo "FACTORY RESET" > /dev/console
26 jffs2reset -y && reboot &
27 fi
28 ;;
29 esac
30
31 return 0