head	1.32;
access;
symbols
	RELENG_5_2_1_RELEASE:1.29
	RELENG_5_2_0_RELEASE:1.29
	RELENG_5_2:1.29.0.2
	RELENG_5_2_BP:1.29
	RELENG_5_1_0_RELEASE:1.25
	RELENG_5_1:1.25.0.2
	RELENG_5_1_BP:1.25
	RELENG_5_0_0_RELEASE:1.23
	RELENG_5_0:1.23.0.2
	RELENG_5_0_BP:1.23
	old_RELENG_4_6_1_RELEASE:1.5.2.12
	old_RELENG_4_6_0_RELEASE:1.5.2.12
	old_RELENG_4_6:1.5.2.12.0.2
	old_RELENG_4_6_BP:1.5.2.12
	old_RELENG_4_5_0_RELEASE:1.5.2.9
	old_RELENG_4_5:1.5.2.9.0.2
	old_RELENG_4_5_BP:1.5.2.9
	old_RELENG_4_4_0_RELEASE:1.5.2.8
	old_RELENG_4_4:1.5.2.8.0.2
	old_RELENG_4_4_BP:1.5.2.8
	old_RELENG_4_3_0_RELEASE:1.5.2.5
	old_RELENG_4_3:1.5.2.5.0.2
	old_RELENG_4_3_BP:1.5.2.5
	old_RELENG_4_2_0_RELEASE:1.5.2.2
	old_RELENG_4_1_1_RELEASE:1.5.2.1
	old_PRE_SMPNG:1.6
	old_RELENG_4_1_0_RELEASE:1.5.2.1
	old_RELENG_3_5_0_RELEASE:1.2.2.1
	old_RELENG_4_0_0_RELEASE:1.5
	old_RELENG_4:1.5.0.2
	old_RELENG_4_BP:1.5
	old_RELENG_3_4_0_RELEASE:1.2.2.1
	old_RELENG_3_3_0_RELEASE:1.2.2.1
	old_RELENG_3_2_PAO:1.2.2.1.0.2
	old_RELENG_3_2_PAO_BP:1.2.2.1
	old_RELENG_3_2_0_RELEASE:1.2.2.1
	old_RELENG_3:1.2.0.2;
locks; strict;
comment	@# @;


1.32
date	2004.03.23.23.22.34;	author brooks;	state dead;
branches;
next	1.31;

1.31
date	2004.03.08.12.25.05;	author pjd;	state Exp;
branches;
next	1.30;

1.30
date	2004.01.05.19.14.47;	author brooks;	state Exp;
branches;
next	1.29;

1.29
date	2003.10.13.08.18.05;	author dougb;	state Exp;
branches;
next	1.28;

1.28
date	2003.10.03.19.57.58;	author phk;	state Exp;
branches;
next	1.27;

1.27
date	2003.10.03.19.07.31;	author phk;	state Exp;
branches;
next	1.26;

1.26
date	2003.10.03.18.26.33;	author phk;	state Exp;
branches;
next	1.25;

1.25
date	2003.02.15.16.34.14;	author jhay;	state Exp;
branches;
next	1.24;

1.24
date	2002.12.22.22.18.41;	author dillon;	state Exp;
branches;
next	1.23;

1.23
date	2002.10.12.10.31.31;	author schweikh;	state Exp;
branches;
next	1.22;

1.22
date	2002.10.01.13.29.44;	author ru;	state Exp;
branches;
next	1.21;

1.21
date	2002.09.22.09.48.02;	author phk;	state Exp;
branches;
next	1.20;

1.20
date	2002.06.25.01.52.33;	author bsd;	state Exp;
branches;
next	1.19;

1.19
date	2002.06.13.22.14.36;	author gordon;	state Exp;
branches;
next	1.18;

1.18
date	2002.03.07.07.17.15;	author obrien;	state Exp;
branches;
next	1.17;

1.17
date	2002.02.23.01.49.20;	author obrien;	state Exp;
branches;
next	1.16;

1.16
date	2002.02.22.19.05.22;	author obrien;	state Exp;
branches;
next	1.15;

1.15
date	2001.12.26.17.18.39;	author rwatson;	state Exp;
branches;
next	1.14;

1.14
date	2001.11.27.22.12.27;	author rwatson;	state Exp;
branches;
next	1.13;

1.13
date	2001.10.17.14.30.19;	author bsd;	state Exp;
branches;
next	1.12;

1.12
date	2001.06.01.10.07.15;	author ru;	state Exp;
branches;
next	1.11;

1.11
date	2001.05.09.15.13.51;	author bsd;	state Exp;
branches;
next	1.10;

1.10
date	2001.05.01.20.13.59;	author phk;	state Exp;
branches;
next	1.9;

1.9
date	2001.04.25.05.46.40;	author imp;	state Exp;
branches;
next	1.8;

1.8
date	2001.04.24.07.02.01;	author imp;	state Exp;
branches;
next	1.7;

1.7
date	2000.10.08.19.18.24;	author obrien;	state Exp;
branches;
next	1.6;

1.6
date	2000.04.27.08.43.48;	author sheldonh;	state Exp;
branches;
next	1.5;

1.5
date	2000.01.06.18.17.38;	author luigi;	state Exp;
branches
	1.5.2.1;
next	1.4;

1.4
date	99.09.13.17.09.07;	author peter;	state Exp;
branches;
next	1.3;

1.3
date	99.09.13.15.44.18;	author sheldonh;	state Exp;
branches;
next	1.2;

1.2
date	99.02.10.18.08.16;	author jkh;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	99.02.09.17.17.18;	author dillon;	state Exp;
branches;
next	;

1.2.2.1
date	99.03.09.17.04.40;	author luigi;	state Exp;
branches;
next	;

1.5.2.1
date	2000.05.28.19.17.15;	author asmodai;	state Exp;
branches;
next	1.5.2.2;

1.5.2.2
date	2000.10.30.10.40.11;	author obrien;	state Exp;
branches;
next	1.5.2.3;

1.5.2.3
date	2001.03.06.01.58.45;	author obrien;	state Exp;
branches;
next	1.5.2.4;

1.5.2.4
date	2001.03.06.02.15.04;	author obrien;	state Exp;
branches;
next	1.5.2.5;

1.5.2.5
date	2001.04.17.15.52.28;	author luigi;	state Exp;
branches;
next	1.5.2.6;

1.5.2.6
date	2001.04.22.23.14.46;	author bsd;	state Exp;
branches;
next	1.5.2.7;

1.5.2.7
date	2001.05.11.17.46.57;	author bsd;	state Exp;
branches;
next	1.5.2.8;

1.5.2.8
date	2001.07.24.09.49.37;	author dd;	state Exp;
branches;
next	1.5.2.9;

1.5.2.9
date	2001.11.02.23.20.43;	author bsd;	state Exp;
branches;
next	1.5.2.10;

1.5.2.10
date	2002.02.12.17.25.11;	author luigi;	state Exp;
branches;
next	1.5.2.11;

1.5.2.11
date	2002.02.12.18.36.23;	author luigi;	state Exp;
branches;
next	1.5.2.12;

1.5.2.12
date	2002.03.15.08.00.37;	author luigi;	state Exp;
branches;
next	1.5.2.13;

1.5.2.13
date	2002.07.04.13.22.35;	author bsd;	state Exp;
branches;
next	;


desc
@@


1.32
log
@Overhaul the /etc/rc.d/diskless script by splitting it out into
hostname, resolve, tmp, and var scripts.  The latter three are new and
were repo copied.  These scripts no longer depend on being booted with
and NFS root instead attempt to automaticly create mfs /tmp and /var
volumes if the they are not writable.  This behavior can be overridden
in /etc/rc.conf.

Reviewed by:    luigi, pjd
@
text
@#!/bin/sh
#
# Copyright (c) 1999  Matt Dillon
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD: src/etc/rc.d/diskless,v 1.31 2004/03/08 12:25:05 pjd Exp $
#

# PROVIDE: diskless
# REQUIRE: initdiskless rcconf mountcritlocal
# BEFORE: addswap random
# KEYWORD: FreeBSD nojail

dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
[ ${dlv:=0} -eq 0 ] && exit 0

name="diskless2"

# Provide a function for normalizing the mounting of memory
# filesystems.  This should allow the rest of the code here to remain
# as close as possible between 5-current and 4-stable.
#   $1 = size
#   $2 = mount point
#   $3 = (optional) bytes-per-inode
mount_md() {
	if [ -n "$3" ]; then
		bpi="-i $3"
	fi
	/sbin/mdmfs $bpi -s $1 -M md $2
}

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/rc.subr ]; then
	. /etc/rc.subr
	load_rc_config $name
elif [ -r /etc/defaults/rc.conf ]; then
	. /etc/defaults/rc.conf
	source_rc_confs
elif [ -r /etc/rc.conf ]; then
	. /etc/rc.conf
fi

# If we do not have a writable /var, create a memory
# filesystem for /var.  We don't have /usr yet so
# use mkdir instead of touch to test.  We want mount
# to record its mounts so we have to make sure /var/db
# exists before doing the mount -a.
#
if (/bin/mkdir /var/.diskless 2> /dev/null); then
        rmdir /var/.diskless
else
	echo "+++ mount_md of /var"
	mount_md ${varsize:=32m} /var
fi

if [ ! -d /var/db ]; then
	mkdir /var/db
fi

# Now we need the rest of our mounts, particularly /usr
#
mount -a       # chown and chgrp are in /usr

# Populate /var
#
echo "+++ populate /var using /etc/mtree/BSD.var.dist"
/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var > /dev/null
case ${sendmail_enable} in
[Nn][Oo][Nn][Ee])
	;;
*)
	/usr/sbin/mtree -deU -f /etc/mtree/BSD.sendmail.dist -p / > /dev/null
	;;
esac

echo "+++ create log files based on the contents of /etc/newsyslog.conf"
LOGFILES=`/usr/bin/awk '$1 != "#" { printf "%s ", $1 } ' /etc/newsyslog.conf`
if [ -n "$LOGFILES" ]; then
	/usr/bin/touch $LOGFILES
fi

echo "+++ create lastlog"
/usr/bin/touch /var/log/lastlog

# Make sure our aliases database is uptodate, the aliases may have
# been overriden in /conf.
#
case ${sendmail_enable} in
[Nn][Oo][Nn][Ee])
	;;
*)
	/usr/bin/newaliases
	;;
esac

# XXX make sure to create one dir for each printer as requested by lpd
#
# If we do not have a writable /tmp, create a memory
# filesystem for /tmp.  If /tmp is a symlink (e.g. to /var/tmp,
# then it should already be writable).
#
if (/bin/mkdir /tmp/.diskless 2> /dev/null); then
	rmdir /tmp/.diskless
else
	if [ -h /tmp ]; then
		echo "*** /tmp is a symlink to a non-writable area!"
		echo "dropping into shell, ^D to continue anyway."
		/bin/sh
	else
		mount_md ${tmpsize:=20480} /tmp
		chmod 01777 /tmp
	fi
fi

if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
	# we have DEVFS, no worries...
	true
elif (/bin/mkdir /dev/.diskless 2> /dev/null); then
	# if /dev is writable assume it has already been populated
	# via /etc/rc.d/initdiskless
	#
	rmdir /dev/.diskless
else
	(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
	mount_md 4096 /dev 512
	(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
	rm -f /tmp/dev.tmp
fi

# generate our hostname
#
if [ -z "`hostname -s`" -a \
    "x`/bin/kenv dhcp.host-name`" != "x" ]; then
        hostname=`/bin/kenv dhcp.host-name`
        hostname $hostname
	echo "Hostname is $hostname"
fi

# if the info is available via dhcp/kenv
# build the resolv.conf
#
if [ ! -e /etc/resolv.conf -a \
    "x`/bin/kenv dhcp.domain-name-servers`" != "x" ]; then
        echo domain `/bin/kenv dhcp.domain-name` > /etc/resolv.conf

        set `/bin/kenv dhcp.domain-name-servers`
        for ns in `IFS=','; echo $*`; do
                echo nameserver $ns >> /etc/resolv.conf;
        done
fi

@


1.31
log
@Mark scripts as not usable inside a jail by adding keyword 'nojail'.

Some suggestions from:	rwatson, Ruben de Groot <mail25@@bzerk.org>
@
text
@d27 1
a27 1
# $FreeBSD$
@


1.30
log
@Don't run newaliases if sendmail_enable=NONE.

Submitted by:	Matt Peterson <matt at peterson dot org>
Approved by:	silence on freebsd-rc
@
text
@d33 1
a33 1
# KEYWORD: FreeBSD
@


1.29
log
@Update references to rc.diskless[12]
@
text
@d110 7
a116 1
/usr/bin/newaliases
@


1.28
log
@Fix typo.

Spotted by:	"Bjoern A. Zeeb" <bzeeb@@zabbadoz.net>
@
text
@d136 1
a136 1
	# via rc.diskless1
@


1.27
log
@More checking if kenv actually know something.

Guard against test(1)-unfriendly outputs from kenv.
@
text
@d149 1
a149 1
    "x`/bin/kenv dhdp.host-name`" != "x" ]; then
@


1.26
log
@In case we have no /etc/resolv.conf, don't try to make it out of
thin blue air if the kenv doesn't have any info.

This improves the truth value of the comment above significantly and
reduces the bogous output on the console considerably.
@
text
@d148 2
a149 1
if [ -z "`hostname -s`" ]; then
d158 2
a159 1
if [ ! -e /etc/resolv.conf -a `/bin/kenv dhcp.domain-name-servers` != "" ]; then
@


1.25
log
@kenv moved from /usr/bin/ to /bin/.
@
text
@d157 1
a157 1
if [ ! -e /etc/resolv.conf ]; then
@


1.24
log
@Do not unconditionally load the configuration files for the RCNG case.
Instead, load them as part of the rc.d system.  This allows us to prioritize
the initidiskless script so it runs before the configuration files are loaded
and allows us to get rid of the exit 2 hack in /etc/rc.  The exit 2 never
worked anyway since it did not unset the prior configuration, causing the
diskless code to not operate properly.

Do a major cleanup and revamping of the diskless code for RCNG.  This will
be backported to the non-RCNG scripts as well as -stable.

With suggestions from: Mike Makonnen <mtm@@identd.net>
MFC after:	7 days
@
text
@d149 1
a149 1
        hostname=`/usr/bin/kenv dhcp.host-name`
d158 1
a158 1
        echo domain `/usr/bin/kenv dhcp.domain-name` > /etc/resolv.conf
d160 1
a160 1
        set `/usr/bin/kenv dhcp.domain-name-servers`
@


1.23
log
@Fix style bugs:
* Space -> tabs conversion.
* Removed blanks before semicolon in "if ... ; then".
* Proper indentation of misindented lines.
* Put a full stop after some comments.
* Removed whitespace at end of line.

Approved by:	silence from gordon
@
text
@d31 1
a31 1
# REQUIRE: initdiskless mountcritlocal
d45 4
a48 6
#   $3 = md unit number (ignored in pre 5.0 systems)
#   $4 = (optional) bytes-per-inode
mount_md()
{
	if [ -n "$4" ]; then
		bpi="-i $4"
d50 1
a50 1
	/sbin/mdmfs $bpi -s $1 -M md$3 $2
d65 12
a76 2
echo "+++ mount_md of /var"
mount_md ${varsize:=32m} /var 1
d78 10
d89 1
a89 1
/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var
d94 1
a94 1
	/usr/sbin/mtree -deU -f /etc/mtree/BSD.sendmail.dist -p /
d107 4
a110 6
mount -a       # chown and chgrp are in /usr

# Since we are starting with a very fresh /etc on an MFS:
if [ -d /conf/default/etc ]; then
	newaliases
fi
a111 1
#
d114 3
a116 3

# If /tmp is a symlink, assume it points to somewhere writable, like
# /var/tmp, otherwise, use a small memory filesystem for /tmp.
d118 11
a128 6
# XXX: mtree runs too early to create any directories needed in /tmp,
# so if /var/tmp == /tmp, then you don't get a vi.recover.
#
if [ ! -L /tmp ]; then
	mount_md ${tmpsize:=64m} /tmp 2
	chmod 01777 /tmp
d131 1
a131 1
if sysctl vfs.devfs.generation > /dev/null 2>&1; then
d134 5
a139 1
	# extract a list of device entries, then copy them to a writable fs
d141 1
a141 1
	mount_md 4096 /dev 3 512
d143 1
d145 21
@


1.22
log
@test -h is deprecated; use -L instead.

PR:             bin/40846
@
text
@d58 2
a59 2
        . /etc/rc.subr
        load_rc_config $name
d111 1
a111 1
if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
@


1.21
log
@Use mdmfs(8) rather than rolling our own RAM-disks.

Sponsored by:	DARPA & NAI Labs.
@
text
@d106 1
a106 1
if [ ! -h /tmp ]; then
@


1.20
log
@Apply same fix as Rev 1.19 of /etc/rc.diskless2: create sendmail
required directories if sendmail_enable is not set to "none".

Suggested by:   gordon
@
text
@d52 1
a52 4
	/sbin/mdconfig -a -t malloc -s $1 -u $3
	/sbin/disklabel -r -w md$3 auto
	/sbin/newfs $bpi /dev/md$3c
	/sbin/mount /dev/md$3c $2
@


1.19
log
@Merge in all the changes that Mike Makonnen has been maintaining for a
while. This is only the script pieces, the glue for the build comes next.

Submitted by:   Mike Makonnen <makonnen@@pacbell.net>
Reviewed by:    silence on -current and -hackers
Prodded by:     rwatson
@
text
@d76 7
@


1.18
log
@fix backwards spelling
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.17 2002/02/23 01:49:20 obrien Exp $
d63 7
@


1.17
log
@The usage of 'newaliases' needs to be after we know for sure that /usr
is mounted.

Submitted by:	rizzo
@
text
@d25 1
a25 1
# $FreeBSD$
d78 1
a78 1
if
@


1.16
log
@The existing bazaar and site-specific policy in rc.diskless1 is Just Wrong;
and looks like no other Unix diskless configuration I've ever seen.
Thus allow a more traditional /etc.

Note, the use of an MFS /var should also be settable.
Otherwise installing ports(packages) is just a total PITA.
@
text
@d75 5
@


1.15
log
@o Add a comment indicating that if /tmp==/var/tmp in rc.diskless2, the
  md device and file system creation occurs *after* mtree is run, and
  as such an /var/tmp/* or /tmp/* entries will be under the mountpoint
  (or fail) rather than appearing in the md filesystems.  This prevents
  the creation of vi.recover, and might affect other localizations that
  rely on the mtree calls affecting these directories.
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.14 2001/11/27 22:12:27 rwatson Exp $
d59 1
a59 1
mount_md ${varsize:=65536} /var 1
d86 1
a86 1
	mount_md ${tmpsize:=20480} /tmp 2
@


1.14
log
@Remeber to set the permissions on an md-backed /tmp to 01777, rather than
using the default of 0755.
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.13 2001/10/17 14:30:19 bsd Exp $
d81 4
@


1.13
log
@Ensure that /var/log/lastlog exists so that login doesn't complain.

Submitted by:	Harti Brandt <brandt@@fokus.gmd.de>
MFC after:	2 weeks
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.12 2001/06/01 10:07:15 ru Exp $
d83 1
@


1.12
log
@Remove vestiges of MFS.
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.11 2001/05/09 15:13:51 bsd Exp $
d69 3
@


1.11
log
@  * Simplify the population of the /etc memory filesystem.  To avoid
    the null mount, we currently create a temporary mfs on /tmp, copy
    /etc to /tmp, then mount /etc as mfs and copy everything back from
    /tmp, then delete the /tmp mfs.

    The patch eliminates the temporary /tmp mfs and the subsequent
    copying and simply populates the /etc mfs by copying from
    /conf/default/etc.  This requires that /conf/default/etc contain a
    complete copy of all the /etc stuff instead of just overrides.  I
    don't think that is too much of an extra step in setting up a
    diskless environment.

  * Provide the ability to make /tmp a memory filesystem independent
    of /var.  This removes the requirement that /tmp be a symlink to
    /var/tmp and this makes the diskless code work with the default
    filesystem layout.  If a seperate /tmp memory filesystem is
    created, the 'tmpsize' environment variable is used to determine
    its size (default to 10 Meg).

  * Reduce diffs between the -current and -stable versions of these
    files to a bare minimum.  Only the definition of the shell
    function 'mount_md' is different.

Not Objected to by: -arch@@, -small@@

MFC after: 2 days
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.10 2001/05/01 20:13:59 phk Exp $
d58 1
a58 1
echo "+++ mfs_mount of /var"
@


1.10
log
@Don't mount a md(4) over /dev on DEVFS enabled diskless systems.
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.9 2001/04/25 05:46:40 imp Exp $
d32 7
d40 3
d45 1
a45 1
	/sbin/newfs /dev/md$3c
d59 1
a59 1
mount_md ${varsize:=65536} /var 2
d76 5
a80 5
# We assume that /tmp is symlinked to /var/tmp on the shared root
# partition. mount_null seems to have problems.
#if [ ! -h /tmp -a ! -h /var/tmp ]; then
#	mount_null /var/tmp /tmp
#fi
d88 1
a88 1
	mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
@


1.9
log
@Move to using md.
o create a simple wrapper function mount_md that makes it easy to
  move from mount_mfs.

# NOTE: you will need to MAKEDEV md[0123] in order for this to work.

Reviewed by: bsd, keichii
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.8 2001/04/24 07:02:01 imp Exp $
d72 9
a80 5
# extract a list of device entries, then copy them to a writable partition
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
echo "+++ mount_mfs of /dev"
mount_md 4096 /dev 3
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
@


1.8
log
@MFS: the MFS still applies to -current until such time as someone fixes
rc.diskless2 to use mdconfig rather than mount_mfs.  These changes are
still relevant to -current.
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.7 2000/10/08 19:18:24 obrien Exp $
d32 7
d49 1
a49 1
mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
d75 1
a75 1
mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
@


1.7
log
@Add copyright notices.  Other systems have been barrowing our /etc files
w/o giving any credit.
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.6 2000/04/27 08:43:48 sheldonh Exp $
d41 1
d43 12
a54 12
var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
	spool/output/lpd"
for i in ${var_dirs}
do
    mkdir /var/${i}
done
chmod 755 /var/run
chmod 755 /var/db
chmod 755 /var/spool
chmod 1777 /var/tmp
chown -R root.daemon /var/spool/output
chgrp daemon /var/spool/lpd
d59 5
a63 3
if [ ! -h /tmp -a ! -h /var/tmp ]; then
	mount_null /var/tmp /tmp
fi
d67 1
@


1.6
log
@Add to defaults/rc.conf a new function source_rc_confs which rc
scripts may use to source safely overrides in ${rc_conf_files}
files.

This protects users who insist on the bad practice of copying
/etc/defaults/rc.conf to /etc/rc.conf from a recursive loop
that exhausts available file descriptors.

Several people have expressed interest in breaking this function
out into its own shell script.  Anyone who wants to embark on
such an undertaking would do well to study the attributed PR.

PR:		17595
Reported by:	adrian
Submitted by:	Doug Barton <Doug@@gorean.org>
@
text
@d1 27
a27 1
# $FreeBSD: src/etc/rc.diskless2,v 1.5 2000/01/06 18:17:38 luigi Exp $
@


1.5
log
@Cleanup diskless support in current, mostly aligning it to the one
in the 3.x branch. Also remove the dependency on /usr to find the
boot address/interface.
Mostly-submitted-abd-tested-by: MIHIRA Sanpei Yoshiro <sanpei@@sanpei.org>
@
text
@d1 1
a1 1
# $FreeBSD: src/etc/rc.diskless2,v 1.4 1999/09/13 17:09:07 peter Exp $
d10 1
@


1.5.2.1
log
@MFC:	- add source_rc_confs

Reminded of, while working on the readline MFC, by:
	Mike Harding <mvh@@ix.netcom.com>
@
text
@d1 1
a1 1
# $FreeBSD: src/etc/rc.diskless2,v 1.5 2000/01/06 18:17:38 luigi Exp $
a9 1
	source_rc_confs
@


1.5.2.2
log
@MFC: Add copyright.
@
text
@d1 1
a1 27
# Copyright (c) 1999  Matt Dillon
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#

@


1.5.2.3
log
@MFC: add copyright notices
@
text
@d25 1
a25 27
# Copyright (c) 1999  Matt Dillon
#

# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD: src/etc/rc.diskless2,v 1.5.2.2 2000/10/30 10:40:11 obrien Exp $
@


1.5.2.4
log
@Grrr. patch really did a number on me with these.
@
text
@d25 27
a51 1
# $FreeBSD: src/etc/rc.diskless2,v 1.5.2.3 2001/03/06 01:58:45 obrien Exp $
@


1.5.2.5
log
@Fixes for diskless support.
in /etc/rc, let rc.diskless2 do the necessary mounts instead of
running mount -a -t nonfs

in /etc/rc.diskless2, do the various mounts in the right order

Approved-by: jkh
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.5.2.4 2001/03/06 02:15:04 obrien Exp $
a40 1
echo "+++ mfs_mount of /var"
a43 1
echo "+++ mfs_mount of /var"
d48 3
a50 1
chmod 755 /var/run /var/db /var/spool
a53 2

mount -a       # chown and chgrp are in /usr
d58 3
a60 5
# We assume that /tmp is symlinked to /var/tmp on the shared root
# partition. mount_null seems to have problems.
#if [ ! -h /tmp -a ! -h /var/tmp ]; then
#	mount_null /var/tmp /tmp
#fi
a63 1
echo "+++ mount_mfs of /dev"
@


1.5.2.6
log
@(This is an intentional direct commit to -stable.  The MFS stuff
 doesn't really apply to -current anymore.)

Populate and set permissions on /var using mtree and
/etc/mtree/BSD.var.dist instead of hardcoding the directories and
permissions within this script.

Create initial log files based on the contents of /etc/newsyslog.conf.

Reviewed by:	luigi
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.5.2.5 2001/04/17 15:52:28 luigi Exp $
d43 11
a53 9

echo "+++ populate /var using /etc/mtree/BSD.var.dist"
/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var

echo "+++ create log files based on the contents of /etc/newsyslog.conf"
LOGFILES=`/usr/bin/awk '$1 != "#" { printf "%s ", $1 } ' /etc/newsyslog.conf`
if [ -n "$LOGFILES" ]; then
	/usr/bin/touch $LOGFILES
fi
a55 1

@


1.5.2.7
log
@MFC: /etc bootstrap simplifications, ability to make /tmp a seperate
     memory filesystem, minimize differences between -current and
     releng_4.
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.5.2.6 2001/04/22 23:14:46 bsd Exp $
a31 14
# Provide a function for normalizing the mounting of memory
# filesystems.  This should allow the rest of the code here to remain
# as close as possible between 5-current and 4-stable.
#   $1 = size
#   $2 = mount point
#   $3 = md unit number (ignored in pre 5.0 systems)
#   $4 = (optional) bytes-per-inode
mount_md() {
	if [ -n "$4" ]; then
		bpi="-i $4"
	fi
	/sbin/mount_mfs -s $1 -T qp120at $bpi dummy $2
}

d42 1
a42 1
mount_md ${varsize:=65536} /var 1
d59 11
a69 15
# If /tmp is a symlink, assume it points to somewhere writable, like
# /var/tmp, otherwise, use a small memory filesystem for /tmp.
if [ ! -h /tmp ]; then
	mount_md ${tmpsize:=20480} /tmp 2
fi

if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
	# we have DEVFS, no worries...
	true
else
	# extract a list of device entries, then copy them to a writable fs
	(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
	mount_md 4096 /dev 3 512
	(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
fi
@


1.5.2.8
log
@Removing old, broken DEVFS from -stable phase one: remove support
code, everything under #ifdef DEVFS (and thus opt_devfs.h), and most
references to the DEVFS routines.  Code that really couldn't be
reached was left alone.  Removal of the actual DEVFS implementation
will come later.

Approved by:	-stable
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.5.2.7 2001/05/11 17:46:57 bsd Exp $
d79 9
a87 4
# extract a list of device entries, then copy them to a writable fs
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
mount_md 4096 /dev 3 512
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
@


1.5.2.9
log
@MFC Rev 1.13, ensure that /var/log/lastlog exists so that login
doesn't complain.
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.5.2.8 2001/07/24 09:49:37 dd Exp $
a65 3

echo "+++ create lastlog"
/usr/bin/touch /var/log/lastlog
@


1.5.2.10
log
@Fix the scripts for diskless boot. Apart from various changes in the
comments to reflect reality and explain the boot process a bit better,
the main changes are the following:

rc.diskless1:
	Use -b 4096 -f 1024 as mount parameters, and increase the
	/etc MFS partition size to 8192 blocks.
	Initially populate /etc from /conf/base/etc

rc.diskless2:
	Use -b 4096 -f 1024 as mount parameters, move "mount -a"
	up a bit so various utilities located in /usr can be
	actually run when /usr is not on the same filesystem as /
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.5.2.9 2001/11/02 23:20:43 bsd Exp $
d43 1
a43 1
	/sbin/mount_mfs -s $1 -T qp120at -b 4096 -f 1024 $bpi dummy $2
a57 2
mount -a       # chown and chgrp are in /usr

d69 2
@


1.5.2.11
log
@Make the fs use 8k/1k blocks as 4:1 ratios are reported to
give trouble sometimes. Probably 4096/512 would be ok too, but
since i do not have a chance now to test it thoroughly i prefer
to stay on the safe side (8k/1k is what was used before 4.5).

Suggested-by: Warner Losh
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.5.2.10 2002/02/12 17:25:11 luigi Exp $
d43 1
a43 1
	/sbin/mount_mfs -s $1 -T qp120at -b 8192 -f 1024 $bpi dummy $2
@


1.5.2.12
log
@Two [minor] performance fixes for diskless configurations:
when copying large trees into /etc and /dev, try to fetch the
content from a cpio archive if there is one available, so the
operation does not take multiple RTTs for each individual file.
clone_root has been updated to generate the cpio archives,
rc.diskless* to make use of them.

Not committed to -current yet because the relevant files are
already slightly different in the two branches, and I would like
to have a chance to test it there first before resyncing the two
versions.
@
text
@d25 1
a25 1
# $FreeBSD: src/etc/rc.diskless2,v 1.5.2.11 2002/02/12 18:36:23 luigi Exp $
d82 2
a83 9
# Extract a list of device entries, then copy them to a writable fs.
# The list can be long, so if there is already a cpio archive prepared
# for us, use that one instead.

if [ -f /conf/dev.cpio.gz ] ; then
	ln -s /conf/dev.cpio.gz /tmp/dev.cpio.gz
else
	(cd /; find -x dev | cpio --create -H newc | gzip) > /tmp/dev.cpio.gz
fi
d85 1
a85 1
(cd /; gzip -dc /tmp/dev.cpio.gz | cpio --extract -H newc -d )
@


1.5.2.13
log
@MFC Rev 1.19: Create sendmail required directories if sendmail is
              enabled.

PR:	misc/39350
@
text
@d25 1
a25 1
# $FreeBSD$
a61 7
case ${sendmail_enable} in
[Nn][Oo][Nn][Ee])
	;;
*)
	/usr/sbin/mtree -deU -f /etc/mtree/BSD.sendmail.dist -p /
	;;
esac
@


1.4
log
@Add/adjust some $FreeBSD$ tags.

Noted by:	Doug <Doug@@gorean.org>
@
text
@d1 1
a1 1
# $FreeBSD: src/etc/rc.diskless2,v 1.3 1999/09/13 15:44:18 sheldonh Exp $
d14 7
a20 4
mount_mfs -s ${var_run_sectors:=2048} -T qp120at dummy /var/run
mount_mfs -s ${var_db_sectors:=16384} -T qp120at dummy /var/db
mount_mfs -s ${var_tmp_sectors:=65536} -T qp120at dummy /var/tmp
mount_mfs -s ${var_spool_sectors:=65536} -T qp120at dummy /var/spool
d25 5
d35 1
a35 7
mkdir /var/spool/mqueue
mkdir /var/spool/lpd
mkdir /var/spool/output
mkdir /var/spool/output/lpd
chown -R root.daemon /var/spool/output
chgrp daemon /var/spool/lpd

@


1.3
log
@Apply a consistent style to most of the etc scripts.  Particularly, use
case instead of test where appropriate, since case allows case is a sh
builtin and (as a side-effect) allows case-insensitivity.

Changes discussed on freebsd-hackers.

Submitted by:	Doug Barton <Doug@@gorean.org>
@
text
@d1 1
a1 2
#
#$FreeBSD$
@


1.2
log
@Use /etc/defaults/rc.conf everywhere, falling back to /etc/rc.conf
as necessary (for half-assed upgrades).
@
text
@d1 3
d9 1
a9 1
if [ -f /etc/defaults/rc.conf ]; then
d11 1
a11 1
elif [ -f /etc/rc.conf ]; then
d35 1
a35 1
( cd /; find -x dev | cpio -o -H newc ) > /tmp/dev.tmp
d37 1
a37 2
( cd /; cpio -i -H newc -d < /tmp/dev.tmp )

@


1.2.2.1
log
@MFC: bring support for diskless in RELENG_3
@
text
@d12 4
a15 7
mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
	spool/output/lpd"
for i in $var_dirs
do
    mkdir /var/$i
done
a19 5
chown -R root.daemon /var/spool/output
chgrp daemon /var/spool/lpd
#
# XXX make sure to create one dir for each printer as requested by lpd
#
d25 7
a31 1
# extract a list of device entries, then copy them to a writable partition
@


1.1
log
@    Revamp rc.diskless.  Split into rc.diskless1 and rc.diskless2.  provide
    more opportunities for overriding.  Clean up /etc/rc ( remove conf_dir,
    remove startup mount special cases, remove other special cases )
@
text
@d6 4
a9 3

if [ -f /etc/rc.conf ]; then
        . /etc/rc.conf
@

