freewrt_2_0
|
Last change
on this file since 03abecc was 03abecc, checked in by Waldemar Brodkorb <wbx@…>, 4 months ago |
|
fix failsafe mode, use modern buttons and leds support
|
-
Property mode
set to
100755
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | #!/bin/sh
|
|---|
| 2 |
|
|---|
| 3 | # CONFIGURE
|
|---|
| 4 | EVENT_DEV="/dev/input/event0" # change if your reset button is on a different event device
|
|---|
| 5 | KEY_CODE="KEY_RESTART" # as reported by evtest
|
|---|
| 6 | LED_PATH="/sys/class/leds/bcm47xx:green:dmz" # adjust to your LED name from ls /sys/class/leds
|
|---|
| 7 | FAILSAFE_IP="192.168.1.1"
|
|---|
| 8 | FAILSAFE_BCAST="192.168.1.255"
|
|---|
| 9 |
|
|---|
| 10 | # Bring up LAN
|
|---|
| 11 | ip link set up dev eth0
|
|---|
| 12 | ip addr add ${FAILSAFE_IP}/24 broadcast ${FAILSAFE_BCAST} dev eth0
|
|---|
| 13 |
|
|---|
| 14 | # Warn the user
|
|---|
| 15 | netmsg ${FAILSAFE_BCAST} "Press reset now, to enter Failsafe!"
|
|---|
| 16 | echo "Press reset now to enter Failsafe!"
|
|---|
| 17 | sleep 2 &
|
|---|
| 18 |
|
|---|
| 19 | # Check for reset press during the 2s window
|
|---|
| 20 | # We'll read the event stream for KEY_RESTART with value 1 (press)
|
|---|
| 21 | pressed=0
|
|---|
| 22 | timeout 2 sh -c "
|
|---|
| 23 | evtest ${EVENT_DEV} 2>/dev/null | \
|
|---|
| 24 | grep -m1 '${KEY_CODE}.*value 1' && exit 0 || exit 1
|
|---|
| 25 | "
|
|---|
| 26 | if [ $? -eq 0 ]; then
|
|---|
| 27 | pressed=1
|
|---|
| 28 | fi
|
|---|
| 29 |
|
|---|
| 30 | if [ "$pressed" -eq 1 ]; then
|
|---|
| 31 | # Blink LED in background
|
|---|
| 32 | (
|
|---|
| 33 | while :; do
|
|---|
| 34 | echo 1 > ${LED_PATH}/brightness
|
|---|
| 35 | sleep 0.5
|
|---|
| 36 | echo 0 > ${LED_PATH}/brightness
|
|---|
| 37 | sleep 0.5
|
|---|
| 38 | done
|
|---|
| 39 | ) &
|
|---|
| 40 |
|
|---|
| 41 | netmsg ${FAILSAFE_BCAST} "Entering Failsafe!"
|
|---|
| 42 | telnetd
|
|---|
| 43 | exit 1
|
|---|
| 44 | else
|
|---|
| 45 | ip addr flush dev eth0
|
|---|
| 46 | fi
|
|---|
| 47 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.