255cc91d94
git-svn-id: svn://svn.openwrt.org/openwrt/packages@24696 3c298f89-4303-0410-b956-a3cf2f4a3e73
32 lines
856 B
Bash
Executable File
32 lines
856 B
Bash
Executable File
#!/bin/sh
|
|
|
|
system_config() {
|
|
config_get button "$1" button "reset"
|
|
config_get action "$1" action "pressed"
|
|
config_get timeout "$1" timeout "5"
|
|
}
|
|
|
|
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"
|
|
|
|
[ "$ACTION" = "$action" ] && {
|
|
|
|
if [ "$timeout" -gt 0 ]
|
|
then
|
|
sleep "$timeout" && firstboot && reboot &
|
|
echo $! > /tmp/run/restorefactory.pid
|
|
logger -p user.info -t "restorefactory" "restoring to factory defaults in $timeout seconds"
|
|
elif [ "$timeout" -eq 0 ]
|
|
then
|
|
firstboot && reboot &
|
|
else
|
|
logger -p user.info -t "restorefactory" "invalid timeout value ($timeout)"
|
|
fi
|
|
}
|
|
}
|
|
|