lftp: moved to github
[openwrt/svn-archive/packages.git] / utils / restorefactory / files / hotplug_restorefactory
1 #!/bin/sh
2
3 system_config() {
4 config_get button "$1" button "reset"
5 config_get action "$1" action "pressed"
6 config_get timeout "$1" timeout "5"
7 }
8
9 config_load system
10 config_foreach system_config restorefactory
11
12 [ "$BUTTON" = "$button" ] && {
13
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"
15
16 [ "$ACTION" = "$action" ] && {
17
18 if [ "$timeout" -gt 0 ]
19 then
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 ]
24 then
25 firstboot && reboot &
26 else
27 logger -p user.info -t "restorefactory" "invalid timeout value ($timeout)"
28 fi
29 }
30 }
31