Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:hardware:hardware.button [2022/04/22 16:16] – [Examples] move chmod from warning into code introt | docs:guide-user:hardware:hardware.button [2022/04/27 15:48] – [Attach functions to a push button] some1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| There several ways for controlling buttons in OpenWrt. | There several ways for controlling buttons in OpenWrt. | ||
| * [[# | * [[# | ||
| - | * [[# | + | * [[# |
| * [[# | * [[# | ||
| Line 218: | Line 218: | ||
| STATEFILE="/ | STATEFILE="/ | ||
| - | if [ " | + | if [ " |
| case " | case " | ||
| - | " | + | " |
| - | " | + | " |
| esac | esac | ||
| else | else | ||
| - | if [ ! -e " | + | if [ -e " |
| - | STATE=" | + | GOAL=" |
| else | else | ||
| - | | + | |
| + | GOAL="off" | ||
| fi | fi | ||
| fi | fi | ||
| - | if [ -z " | + | |
| - | STATE=" | + | if [ "${GOAL}" = "off" ]; then |
| - | fi | + | |
| - | + | ||
| - | if [ "${STATE}" = "on" ]; then | + | |
| /sbin/wifi down | /sbin/wifi down | ||
| - | | + | |
| else | else | ||
| /sbin/wifi up | /sbin/wifi up | ||
| - | | + | |
| + | rm "${STATEFILE}" | ||
| fi | fi | ||
| - | |||
| - | echo " | ||
| EOF | EOF | ||
| chmod u+x / | chmod u+x / | ||