From owner-freebsd-bugs@FreeBSD.ORG Tue Nov 16 17:00:51 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5918C16A4CE for ; Tue, 16 Nov 2004 17:00:51 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2BEF843D5A for ; Tue, 16 Nov 2004 17:00:51 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id iAGH0p6w025839 for ; Tue, 16 Nov 2004 17:00:51 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id iAGH0ooZ025825; Tue, 16 Nov 2004 17:00:50 GMT (envelope-from gnats) Resent-Date: Tue, 16 Nov 2004 17:00:50 GMT Resent-Message-Id: <200411161700.iAGH0ooZ025825@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jose M Rodriguez Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8006A16A4CE for ; Tue, 16 Nov 2004 16:52:53 +0000 (GMT) Received: from smtp2.jazztel.es (smtp2.jazztel.es [62.14.3.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0008C43D1F for ; Tue, 16 Nov 2004 16:52:52 +0000 (GMT) (envelope-from josemi@freebsd.jazztel.es) Received: from antivirus by smtp2.jazztel.es with antivirus id 1CU6ZV-0006eT-00 for FreeBSD-gnats-submit@freebsd.org Tue, 16 Nov 2004 17:52:49 +0100 Received: from [212.106.252.3] (helo=rguez.homeunix.net) by smtp2.jazztel.es with esmtp id 1CU6ZU-0006d5-00 for FreeBSD-gnats-submit@freebsd.org Tue, 16 Nov 2004 17:52:49 +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 iAGGqo7G081530 for ; Tue, 16 Nov 2004 17:52:50 +0100 (CET) (envelope-from freebsd@redesjm.local) Received: (from freebsd@localhost) by redesjm.local (8.13.1/8.13.1/Submit) id iAGGqocd052763; Tue, 16 Nov 2004 17:52:50 +0100 (CET) (envelope-from freebsd) Message-Id: <200411161652.iAGGqocd052763@redesjm.local> Date: Tue, 16 Nov 2004 17:52:50 +0100 (CET) From: Jose M Rodriguez To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/74005: [PATCH] aditional support for /etc/rc.initdiskless X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jose M Rodriguez List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Nov 2004 17:00:51 -0000 >Number: 74005 >Category: bin >Synopsis: [PATCH] aditional support for /etc/rc.initdiskless >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Nov 16 17:00:50 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Jose M Rodriguez >Release: FreeBSD 5.3-STABLE i386 >Organization: Redes JM >Environment: System: FreeBSD orion.redesjm.local 5.3-STABLE FreeBSD 5.3-STABLE #0: Tue Nov 16 13:26:33 CET 2004 root@orion.redesjm.local:/usr/obj/usr/src/sys/ORION i386 >Description: Add aditional support to /etc/rc.initdiskless, in the way of use pax instead of cpio and any version of gzip. This also add suppor for uncompressed pax tarballs (ustar) Working in the way of be capable of remote booting without /rescue or /stand and maintain compatibility with any version of FreeBSD from RELENG_4 >How-To-Repeat: >Fix: This have now very limited test, use with care --- patch-initdiskless begins here --- --- etc/rc.d/initdiskless.orig Thu Oct 28 21:34:40 2004 +++ etc/rc.d/initdiskless Thu Oct 28 21:34:51 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`) --- patch-initdiskless ends here --- >Release-Note: >Audit-Trail: >Unformatted: