2010-05-13 00:52:08 +00:00
|
|
|
#!/bin/sh
|
2010-04-22 15:55:55 +00:00
|
|
|
|
|
|
|
system_config() {
|
2010-05-13 00:52:08 +00:00
|
|
|
config_get button "$1" button "reset"
|
2010-04-22 15:55:55 +00:00
|
|
|
config_get action "$1" action "pressed"
|
2010-05-13 00:52:08 +00:00
|
|
|
config_get timeout "$1" timeout "5"
|
2010-04-22 15:55:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config_load system
|
|
|
|
config_foreach system_config restorefactory
|
|
|
|
|
|
|
|
[ "$BUTTON" = "$button" ] && {
|
|
|
|
|
|
|
|
[ -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"
|
|
|
|
|
2010-05-13 00:52:08 +00:00
|
|
|
[ "$ACTION" = "$action" ] && {
|
2010-04-22 15:55:55 +00:00
|
|
|
|
2010-05-13 00:52:08 +00:00
|
|
|
if [ "$timeout" -gt 0 ]
|
2010-04-22 15:55:55 +00:00
|
|
|
then
|
|
|
|
sleep "$timeout" && firstboot && reboot &
|
2010-05-13 00:52:08 +00:00
|
|
|
echo $! > /tmp/run/restorefactory.pid
|
|
|
|
logger -p user.info -t "restorefactory" "restoring to factory defaults in $timeout seconds"
|
2010-04-22 15:55:55 +00:00
|
|
|
elif [ "$timeout" -eq 0 ]
|
2010-05-13 00:52:08 +00:00
|
|
|
then
|
2010-04-22 15:55:55 +00:00
|
|
|
firstboot && reboot &
|
|
|
|
else
|
|
|
|
logger -p user.info -t "restorefactory" "invalid timeout value ($timeout)"
|
|
|
|
fi
|
2010-05-13 00:52:08 +00:00
|
|
|
}
|
2010-04-22 15:55:55 +00:00
|
|
|
}
|
|
|
|
|