resolv revision 76409
166830Sobrien#!/bin/sh
266830Sobrien#
366830Sobrien# Copyright (c) 1999  Matt Dillon
466830Sobrien# All rights reserved.
566830Sobrien#
666830Sobrien# Redistribution and use in source and binary forms, with or without
766830Sobrien# modification, are permitted provided that the following conditions
866830Sobrien# are met:
966830Sobrien# 1. Redistributions of source code must retain the above copyright
1066830Sobrien#    notice, this list of conditions and the following disclaimer.
1166830Sobrien# 2. Redistributions in binary form must reproduce the above copyright
1266830Sobrien#    notice, this list of conditions and the following disclaimer in the
1366830Sobrien#    documentation and/or other materials provided with the distribution.
1466830Sobrien#
1566830Sobrien# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1666830Sobrien# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1766830Sobrien# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1866830Sobrien# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1966830Sobrien# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2066830Sobrien# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2166830Sobrien# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2266830Sobrien# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2366830Sobrien# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2466830Sobrien# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2551237Speter# $FreeBSD: head/etc/rc.d/resolv 76409 2001-05-09 15:13:51Z bsd $
2651231Ssheldonh#
2766830Sobrien# $FreeBSD: head/etc/rc.d/resolv 76409 2001-05-09 15:13:51Z bsd $
2866830Sobrien#
2943803Sdillon
3043803Sdillon# PROVIDE: diskless
3143803Sdillon# REQUIRE: initdiskless mountcritlocal
3276409Sbsd# BEFORE: addswap random
3376409Sbsd# KEYWORD: FreeBSD
3475931Simp
3576409Sbsddlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
3676409Sbsd[ ${dlv:=0} -eq 0 ] && exit 0
3776409Sbsd
3876409Sbsdname="diskless2"
3976409Sbsd
4076409Sbsd# Provide a function for normalizing the mounting of memory
4176409Sbsd# filesystems.  This should allow the rest of the code here to remain
4276409Sbsd# as close as possible between 5-current and 4-stable.
4375931Simp#   $1 = size
4475931Simp#   $2 = mount point
4576409Sbsd#   $3 = md unit number (ignored in pre 5.0 systems)
4675931Simp#   $4 = (optional) bytes-per-inode
4775931Simpmount_md()
4875931Simp{
4943803Sdillon	if [ -n "$4" ]; then
5043803Sdillon		bpi="-i $4"
5151231Ssheldonh	fi
5243849Sjkh	/sbin/mdconfig -a -t malloc -s $1 -u $3
5359674Ssheldonh	/sbin/disklabel -r -w md$3 auto
5451231Ssheldonh	/sbin/newfs $bpi /dev/md$3c
5543849Sjkh	/sbin/mount /dev/md$3c $2
5643803Sdillon}
5743803Sdillon
5875898Simpecho "+++ mfs_mount of /var"
5976409Sbsdmount_md ${varsize:=65536} /var 1
6075898Simpif [ -r /etc/rc.subr ]; then
6175898Simp        . /etc/rc.subr
6275898Simp        load_rc_config $name
6375898Simpecho "+++ mount_md of /var"
6475898Simpmount_md ${varsize:=32m} /var 1
6575898Simp
6675898Simpecho "+++ populate /var using /etc/mtree/BSD.var.dist"
6775898Simp/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var
6875898Simpcase ${sendmail_enable} in
6975898Simp	/usr/bin/touch $LOGFILES
7075898Simpfi
7175898Simp
7255520Sluigi# Since we are starting with a very fresh /etc on an MFS:
7355520Sluigiif [ -d /conf/default/etc ]; then
7455520Sluigi	newaliases
7543803Sdillonfi
7676409Sbsd
7743803Sdillon#
7876409Sbsd# /var/tmp, otherwise, use a small memory filesystem for /tmp.
7976409Sbsd	mount_md ${tmpsize:=20480} /tmp 2
8076409Sbsd# so if /var/tmp == /tmp, then you don't get a vi.recover.
8176409Sbsd#
8276193Sphkif [ ! -h /tmp ]; then
8376193Sphk	mount_md ${tmpsize:=64m} /tmp 2
8476193Sphk	chmod 01777 /tmp
8576193Sphkfi
8676193Sphk
8776193Sphkif sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
8876409Sbsd	# we have DEVFS, no worries...
8976193Sphk	true
9076193Sphkelse
9143803Sdillon	# extract a list of device entries, then copy them to a writable fs
9243803Sdillon	(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
9343803Sdillon	mount_md 4096 /dev 3 512
9443803Sdillon	(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
9543803Sdillonfi
96