mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 04:33:00 +02:00
common: add support for 'factory' to reset /rw/infix to defaults
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ ${H2}Services:${H0}
|
||||
|
||||
${H2}Tools:${H0}
|
||||
date [-h] Display current time, or sets the system date
|
||||
factory Factory reset the device (on the next boot)
|
||||
hwclock [-h] Query or set the hardware clock (RTC)
|
||||
logout | Ctrl-D Log out from TTY
|
||||
mdio | mvls Low-level MDIO access, also for Marvell switch status
|
||||
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
alias factory='read -N 1 -p "Factory reset requires a reboot, continue (y/N)? " yorn; echo; if [ "$yorn" = "y" ]; then touch /rw/infix/.reset; reboot; fi'
|
||||
@@ -12,7 +12,9 @@
|
||||
|
||||
set -e
|
||||
|
||||
nm=$(basename $0)
|
||||
err=0
|
||||
opt="-k"
|
||||
|
||||
mount_rw()
|
||||
{
|
||||
@@ -28,13 +30,25 @@ mount_rw()
|
||||
if ! mount_rw; then
|
||||
err=1
|
||||
|
||||
logger -k -p user.crit -t "$(basename $0)" \
|
||||
logger $opt -p user.crit -t "$nm" \
|
||||
"No persistent storage found for /rw, falling back to tmpfs."
|
||||
|
||||
mount tmpfs-rw
|
||||
fi
|
||||
|
||||
# fall back to console logging if sysklogd is too old
|
||||
if ! logger -? |grep -q "Log to kernel"; then
|
||||
opt="-c"
|
||||
fi
|
||||
|
||||
# Allow users in wheel group to write to /rw
|
||||
chgrp wheel /rw && chmod g+w /rw
|
||||
|
||||
# Check for factory reset
|
||||
if [ -f /rw/infix/.reset ]; then
|
||||
logger $opt -p user.crit -t "$nm" "Resetting to factory defaults."
|
||||
rm -rf /rw/infix/* /rw/infix/.reset
|
||||
sync
|
||||
fi
|
||||
|
||||
exit $err
|
||||
|
||||
Reference in New Issue
Block a user