From owner-svn-src-stable-12@freebsd.org Mon Nov 19 06:33:39 2018 Return-Path: Delivered-To: svn-src-stable-12@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22279113616A; Mon, 19 Nov 2018 06:33:39 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ADD31850EA; Mon, 19 Nov 2018 06:33:38 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 76B801E744; Mon, 19 Nov 2018 06:33:38 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wAJ6XcUO026195; Mon, 19 Nov 2018 06:33:38 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wAJ6XcVq026194; Mon, 19 Nov 2018 06:33:38 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <201811190633.wAJ6XcVq026194@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Mon, 19 Nov 2018 06:33:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r340610 - stable/12/libexec/rc X-SVN-Group: stable-12 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: stable/12/libexec/rc X-SVN-Commit-Revision: 340610 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: ADD31850EA X-Spamd-Result: default: False [0.66 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_SPAM_MEDIUM(0.12)[0.123,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_SPAM_SHORT(0.53)[0.534,0] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2018 06:33:39 -0000 Author: eugen Date: Mon Nov 19 06:33:38 2018 New Revision: 340610 URL: https://svnweb.freebsd.org/changeset/base/340610 Log: MFC r339465: 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 Modified: stable/12/libexec/rc/rc.initdiskless Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rc/rc.initdiskless ============================================================================== --- stable/12/libexec/rc/rc.initdiskless Mon Nov 19 06:07:17 2018 (r340609) +++ stable/12/libexec/rc/rc.initdiskless Mon Nov 19 06:33:38 2018 (r340610) @@ -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