| #!/bin/sh |
| |
| log() |
| { |
| echo "$0:" "$@" >&2 |
| } |
| |
| log "starting." |
| |
| while :; do |
| log "waiting for reset button." |
| # gpio-mailbox creates reset_button_msecs when ready. |
| wait-until-created /tmp/gpio/reset_button_msecs |
| log "reset button pressed! waiting for button release." |
| if reset-button-held 2000; then |
| log "reset button activated." |
| # kill ledmonitor so avoid other LED changes |
| pkill -9 -f ledmonitor |
| leds x2 2 0 # slow blinky blue light to indicate initial reset mode |
| if reset-button-held 10000; then |
| log "factory reset requested." |
| leds 2 0 2 0 2 0 # fast blinky blue light to indicate full on factory reset |
| zap --i-really-mean-it --erase-backups |
| log "factory reset complete: rebooting in 10 seconds..." |
| sleep 10 |
| else |
| log "reset button: rebooting..." |
| fi |
| leds 0 |
| reboot |
| fi |
| done |