nmap: remove empty folder
[openwrt.org/packages.git] / utils / hotplug_restorefactory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/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
	}
} 


comments