From owner-freebsd-current@FreeBSD.ORG Thu Nov 11 19:18:53 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0C8F416A4CE for ; Thu, 11 Nov 2004 19:18:53 +0000 (GMT) Received: from smtp1.jazztel.es (smtp1.jazztel.es [62.14.3.161]) by mx1.FreeBSD.org (Postfix) with ESMTP id 85D1843D2D for ; Thu, 11 Nov 2004 19:18:52 +0000 (GMT) (envelope-from josemi@freebsd.jazztel.es) Received: from antivirus by smtp1.jazztel.es with antivirus id 1CSKTM-0007Gw-00 for current@freebsd.org Thu, 11 Nov 2004 20:19:08 +0100 Received: from [212.106.238.191] (helo=rguez.homeunix.net) by smtp1.jazztel.es with esmtp id 1CSKTK-0007Fw-00 for current@freebsd.org Thu, 11 Nov 2004 20:19:07 +0100 Received: from redesjm.local (orion.redesjm.local [192.168.254.16]) by rguez.homeunix.net (8.13.1/8.13.1) with ESMTP id iABJIkkx001528 for ; Thu, 11 Nov 2004 20:18:46 +0100 (CET) (envelope-from freebsd@redesjm.local) Received: from localhost (localhost [[UNIX: localhost]]) by redesjm.local (8.13.1/8.13.1/Submit) id iABJIkNj035449 for current@freebsd.org; Thu, 11 Nov 2004 20:18:46 +0100 (CET) (envelope-from freebsd@redesjm.local) From: Jose M Rodriguez To: current@freebsd.org Date: Thu, 11 Nov 2004 20:18:46 +0100 User-Agent: KMail/1.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200411112018.46685.freebsd@redesjm.local> X-AntiVirus: checked by AntiVir Milter (version: 1.1; AVE: 6.28.0.12; VDF: 6.28.0.59; host: antares.redesjm.local) X-Virus-Scanned: by antivirus Subject: initdiskless patch X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Nov 2004 19:18:53 -0000 Hi, This is an absolute _NOT_ tested patch, but an idea that can be even MFC to RELENG_4 comments welcome, -- josemi ----- patch-initdiskless --- /etc/rc.d/initdiskless Tue Oct 26 18:16:19 2004 +++ initdiskless Thu Oct 28 13:42:29 2004 @@ -91,10 +91,15 @@ # initialize it from a template, it is preferrable to specify # it in fstab e.g. as "md /tmp mfs -s=30m,rw 0 0" # +# /conf/T/SUBDIR.pax +# The file is expanded into /SUBDIR (and a memory filesystem +# is created for /SUBDIR if necessary). The presence of this +# file prevents the copy from other sources +# # /conf/T/SUBDIR.cpio.gz -# The file is cpio'd into /SUBDIR (and a memory filesystem is -# created for /SUBDIR if necessary). The presence of this file -# prevents the copy from /conf/T/SUBDIR/ +# The file is expanded into /SUBDIR (and a memory filesystem +# is created for /SUBDIR if necessary). The presence of this +# file prevents the copy from /conf/T/SUBDIR/ # # /conf/T/SUBDIR.remove # The list of paths contained in the file are rm -rf'd @@ -250,6 +255,7 @@ # it before attemping to the remount. This allows the root to be # relocated without needing to change the remount files. # + for i in ${templates} ; do for j in /conf/$i/* ; do # memory filesystem size specification @@ -291,27 +297,56 @@ # so if the cpio archive is present, it prevents the files from dir/ # from being copied. +# a valid gzip +if [ -x /bin/gzip ]; then + use_gunzip="/bin/gzip -d" +elif [ -x /rescue/gzip ]; then + use_gunzip="/rescue/gzip -d" +elif [ -x /stand/gzip ]; then + use_gunzip="/stand/gzip -d" +else + use_gunzip="" +fi + for i in ${templates} ; do - for j in /conf/$i/* ; do - subdir=${j##*/} - if [ -d $j -a ! -f $j.cpio.gz ]; then + for j in /conf/$i/*.pax ; do + subdir=${j%*.pax} + subdir=${subdir##*/} + eval _from=\$md_from_${subdir}_${i} + if [ -r $j -a ! -n "${_from}" ]; then create_md $subdir - cp -Rp $j/* /$subdir + echo "Loading /$subdir from pax archive $j" + (cd / ; /bin/pax -r -pe ${busbir} < $j ) + eval md_from_${subdir}_${i}="$j" fi done - for j in /conf/$i/*.cpio.gz ; do - subdir=${j%*.cpio.gz} - subdir=${subdir##*/} - if [ -f $j ]; then + if [ -n "${use_gunzip}" ]; then + for j in /conf/$i/*.cpio.gz ; do + subdir=${j%*.cpio.gz} + subdir=${subdir##*/} + eval _from=\$md_from_${subdir}_${i} + if [ -r $j -a ! -n "${_from}" ]; then + create_md $subdir + echo "Loading /$subdir from cpio archive $j" + (cd / ; ${use_gunzip} < $j | /bin/pax -r -pe ${subdir} ) + eval md_from_${subdir}_${i}="$j" + fi + done + fi + for j in /conf/$i/* ; do + subdir=${j##*/} + eval _from=\$md_from_${subdir}_${i} + if [ -d $j -a ! -n "${_from}" ]; then create_md $subdir - echo "Loading /$subdir from cpio archive $j" - (cd / ; /stand/gzip -d < $j | /stand/cpio --extract -d ) + echo "Copying /$subdir from $j" + cp -Rp $j/* /$subdir + eval md_from_${subdir}_${i}="$j" fi done for j in /conf/$i/*.remove ; do subdir=${j%*.remove} subdir=${subdir##*/} - if [ -f $j ]; then + if [ -r $j ]; then # doubly sure it is a memory disk before rm -rf'ing create_md $subdir (cd /$subdir; rm -rf `/bin/cat $j`)