diff --git a/board/common/rootfs/bin/help b/board/common/rootfs/bin/help index 74769f9f..6eb55dc7 100755 --- a/board/common/rootfs/bin/help +++ b/board/common/rootfs/bin/help @@ -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 diff --git a/board/common/rootfs/etc/profile.d/factory.sh b/board/common/rootfs/etc/profile.d/factory.sh new file mode 100755 index 00000000..e4f586a5 --- /dev/null +++ b/board/common/rootfs/etc/profile.d/factory.sh @@ -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' diff --git a/board/common/rootfs/lib/infix/mount-rw b/board/common/rootfs/lib/infix/mount-rw index 92990deb..0bf81f5e 100755 --- a/board/common/rootfs/lib/infix/mount-rw +++ b/board/common/rootfs/lib/infix/mount-rw @@ -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