4 config_get button "$1" button "reset"
5 config_get action "$1" action "pressed"
6 config_get timeout "$1" timeout "5"
10 config_foreach system_config restorefactory
12 [ "$BUTTON" = "$button" ] && {
14 [ -f /tmp/run/restorefactory.pid ] && read PID < /tmp/run/restorefactory.pid && kill $PID && rm /tmp/run/restorefactory.pid && logger -p user.info -t "restorefactory" "restore to factory defaults aborted"
16 [ "$ACTION" = "$action" ] && {
18 if [ "$timeout" -gt 0 ]
20 sleep "$timeout" && firstboot && reboot &
21 echo $! > /tmp/run/restorefactory.pid
22 logger -p user.info -t "restorefactory" "restoring to factory defaults in $timeout seconds"
23 elif [ "$timeout" -eq 0 ]
27 logger -p user.info -t "restorefactory" "invalid timeout value ($timeout)"