-
Notifications
You must be signed in to change notification settings - Fork 47
Factory Defaults
thingOS allows the user to restore their device to the "factory" defaults, normally upon pressing and holding a reset button.
If properly configured in os.conf, a GPIO is continuously monitored by the S39factoryreset
init script. If held for a given amount of time to a given "active" level (i.e. reset button pressed), the script will start the factory reset procedure, consisting of (in this order):
- executing the script
/usr/libexec/before-factory-reset
, if present and executable - removing the
data
partition (so it will be created from scratch at next boot) - executing the script
/usr/libexec/after-factory-reset
, if present and executable - rebooting the system
At the very next boot, the system will recreate the data
partition and will initialize it with the factory defaults, if present.
If the /boot/factory-defaults.tar.xz
file is present on a device, it will be used to initialize a freshly created data
partition. The archive is decompressed and its contents are extracted directly in the root of the /data
folder, effectively supplying initial configuration files with their directory structure. This is done by the S01mountall
init script.
The file factory defaults file is preserved across firmware updates, meaning that once copied on the root of the boot
partition, whenever the /sbin/fwupdate
command flashes a new boot
partition, it will make sure to restore this file from the previous boot
partition.
Make sure to set the following variables in os.conf:
-
OS_FACTORY_RESET_GPIO=<your gpio>
(e.g.23
) -
OS_FACTORY_RESET_INPUT=<your input>
(e.g.event0
) OS_FACTORY_RESET_LEVEL=0|1
OS_FACTORY_RESET_HOLD_SECONDS=10
Either set OS_FACTORY_RESET_GPIO
or OS_FACTORY_RESET_INPUT
, not both, depending on whether your reset button is attached to a GPIO or an input (e.g. /dev/input/event0
)
Additionally, if you want to signal a successful reset to the user, you could, for example, flash or turn off a LED in /usr/libexec/after-factory-reset
.
- bluetooth.conf
- captive-portal.conf
- cpufreq.conf
- date.conf
- dnsmasq.conf
- docker-compose.yml
- dtoverlays
- dyndns-update.sh
- environment
- firewall.sh
- fstab.user
- hostapd.conf
- ifalias.conf
- localtime
- modprobe.conf
- modules
- mongodb.conf
- netwatch.conf
- ntp.conf
- os.conf
- proftpd.conf
- redis.conf
- smb.conf
- ssh/config
- ssh/sshd_config
- ssl/domain
- ssl/email
- static_ip.conf
- sysctl.conf
- toemmc.conf
- version
- watchdog.conf
- wpa_supplicant.conf