[packages] restorefactory: add package (closes: #6464)

git-svn-id: svn://svn.openwrt.org/openwrt/packages@21090 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nunojpg
2010-04-22 15:55:55 +00:00
parent 2484c7e47e
commit 742cde3ec3
3 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,31 @@
# /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
}
}

View File

@ -0,0 +1,7 @@
#!/bin/sh
uci add system restorefactory
uci set system.@restorefactory[0].button=reset
uci set system.@restorefactory[0].action=pressed
uci set system.@restorefactory[0].timeout=5
uci commit