source: packages/utils/restorefactory/files/etc/hotplug.d/button/50-restorefactory @ 21440

Last change on this file since 21440 was 21440, checked in by nico, 7 years ago

[packages] restorefactory: cleanup code (closes: #7327)

  • Property svn:executable set to *
File size: 856 bytes
Line 
1#!/bin/sh
2
3system_config() {
4        config_get button "$1" button "reset"
5        config_get action "$1" action "pressed"
6        config_get timeout "$1" timeout "5"
7}
8
9config_load system
10config_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
Note: See TracBrowser for help on using the repository browser.