Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Oct 2018 18:13:51 +0000 (UTC)
From:      Eugene Grosbein <eugen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r339465 - head/libexec/rc
Message-ID:  <201810201813.w9KIDp5S034810@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eugen
Date: Sat Oct 20 18:13:51 2018
New Revision: 339465
URL: https://svnweb.freebsd.org/changeset/base/339465

Log:
  rc.initdiskless: add support for auxiliary NVRAM.
  
  Currently, rc.inidiskless assumes that local system configuration
  changes are kept in some mountable file system. For example,
  nanobsd uses dedicated partition mounted as /cfg for this.
  
  However, small embedded devices like MIPS routers may have no enough flash
  space to keep full-blown file system but have only one or couple
  small flash blocks to keep persistent local configuration overrides.
  
  This change extends rc.initdiskless and introduces ability to run auxiliary
  command /conf/T/M/extract that is supposed to extract configuration overrides
  from such local storage.
  
  For example, the command /conf/default/etc/extract may contain something like:
  
  cd "$1" && bsdcpio --quiet -idu < /dev/map/cfg
  
  bsdcpio command extracts compressed archive from the storage to /etc
  assuming the storage is exposed by the kernel as /dev/map/cfg to userland.
  
  PR:		204215
  MFC after:	1 month

Modified:
  head/libexec/rc/rc.initdiskless

Modified: head/libexec/rc/rc.initdiskless
==============================================================================
--- head/libexec/rc/rc.initdiskless	Sat Oct 20 18:11:46 2018	(r339464)
+++ head/libexec/rc/rc.initdiskless	Sat Oct 20 18:13:51 2018	(r339465)
@@ -111,6 +111,15 @@
 #		created for /SUBDIR if necessary). The presence of this file
 #		prevents the copy from /conf/T/SUBDIR/
 #
+# /conf/T/M/extract
+#		This is alternative to SUBDIR.cpio.gz and remount.
+#		Similar to remount case, a memory filesystem is created
+#		for /M and initialized from a template but no mounting
+#		performed. Instead, this file is run passing /M as singe
+#		argument. It is expected to extract template override to /M
+#		using auxiliary storage found in some embedded systems
+#		having NVRAM too small to hold mountable file system.
+#
 # /conf/T/SUBDIR.remove
 #		The list of paths contained in the file are rm -rf'd
 #		relative to /SUBDIR.
@@ -343,8 +352,8 @@ done
 
 # - Create all required MFS filesystems and populate them from
 #   our templates.  Support both a direct template and a dir.cpio.gz
-#   archive.  Support dir.remove files containing a list of relative
-#   paths to remove.
+#   archive. Support for auxiliary NVRAM. Support dir.remove files containing
+#   a list of relative paths to remove.
 #
 # The dir.cpio.gz form is there to make the copy process more efficient,
 # so if the cpio archive is present, it prevents the files from dir/
@@ -365,6 +374,15 @@ for i in ${templates} ; do
 	    create_md $subdir
 	    echo "Loading /$subdir from cpio archive $j"
 	    (cd / ; /rescue/tar -xpf $j)
+	fi
+    done
+    for j in /conf/$i/*/extract ; do
+	if [ -x $j ]; then
+	    subdir=${j%*/extract}
+	    subdir=${subdir##*/}
+	    create_md $subdir
+	    echo "Loading /$subdir using auxiliary command $j"
+	    $j /$subdir
 	fi
     done
     for j in /conf/$i/*.remove ; do



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201810201813.w9KIDp5S034810>