tmp revision 76193
168583Smarcel#!/bin/sh
268583Smarcel#
368583Smarcel# Copyright (c) 1999  Matt Dillon
468583Smarcel# All rights reserved.
568583Smarcel#
6255676Srdivacky# Redistribution and use in source and binary forms, with or without
768583Smarcel# modification, are permitted provided that the following conditions
868583Smarcel# are met:
968583Smarcel# 1. Redistributions of source code must retain the above copyright
1068583Smarcel#    notice, this list of conditions and the following disclaimer.
1168583Smarcel# 2. Redistributions in binary form must reproduce the above copyright
1268583Smarcel#    notice, this list of conditions and the following disclaimer in the
1368583Smarcel#    documentation and/or other materials provided with the distribution.
14177999Skib#
15227776Slstewart# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16164184Strhodes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17122256Sjhb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18255673Srdivacky# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19122256Sjhb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20161330Sjhb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21161330Sjhb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2268583Smarcel# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2368583Smarcel# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2483366Sjulian# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2583366Sjulian# $FreeBSD: head/etc/rc.d/tmp 76193 2001-05-01 20:13:59Z phk $
2668583Smarcel#
2768583Smarcel# $FreeBSD: head/etc/rc.d/tmp 76193 2001-05-01 20:13:59Z phk $
2868583Smarcel#
2983221Smarcel
3083221Smarcel# PROVIDE: diskless
3183221Smarcel# REQUIRE: initdiskless mountcritlocal
3283221Smarcel
3383221Smarcel#   $1 = size
3483221Smarcel#   $2 = mount point
3583221Smarcel	/sbin/newfs /dev/md$3c
3683221Smarcel#   $4 = (optional) bytes-per-inode
37143198Ssobomaxmount_md()
3883221Smarcel{
3968583Smarcel	if [ -n "$4" ]; then
4068583Smarcel		bpi="-i $4"
4183221Smarcel	fi
4283221Smarcel	/sbin/mdconfig -a -t malloc -s $1 -u $3
4383221Smarcel	/sbin/disklabel -r -w md$3 auto
4483221Smarcel	/sbin/newfs $bpi /dev/md$3c
4568583Smarcel	/sbin/mount /dev/md$3c $2
4683221Smarcel}
4783221Smarcel
4883221Smarcelecho "+++ mfs_mount of /var"
4983221Smarcelmount_md ${varsize:=65536} /var 2
5068583Smarcelif [ -r /etc/rc.subr ]; then
5183221Smarcel        . /etc/rc.subr
5283221Smarcel        load_rc_config $name
5383221Smarcelecho "+++ mount_md of /var"
5468583Smarcelmount_md ${varsize:=32m} /var 1
5583221Smarcel
5683221Smarcelecho "+++ populate /var using /etc/mtree/BSD.var.dist"
5783221Smarcel/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var
5868583Smarcelcase ${sendmail_enable} in
5983221Smarcel	/usr/bin/touch $LOGFILES
6083221Smarcelfi
6168583Smarcel
6283221Smarcel# Since we are starting with a very fresh /etc on an MFS:
6383221Smarcelif [ -d /conf/default/etc ]; then
6483221Smarcel	newaliases
6583221Smarcelfi
6668583Smarcel# We assume that /tmp is symlinked to /var/tmp on the shared root
6783221Smarcel# partition. mount_null seems to have problems.
6883221Smarcel#if [ ! -h /tmp -a ! -h /var/tmp ]; then
6968583Smarcel#	mount_null /var/tmp /tmp
7083221Smarcel#fi
7183221Smarcel#
7268583Smarcelif [ ! -h /tmp ]; then
7383221Smarcel	mount_md ${tmpsize:=64m} /tmp 2
7483221Smarcel	chmod 01777 /tmp
7583221Smarcelfi
7683221Smarcel
7768583Smarcelif sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
7883221Smarcel	mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
7983221Smarcel	true
8083221Smarcelelse
8168583Smarcel	# extract a list of device entries, then copy them to a writable fs
8283221Smarcel	(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
8383221Smarcel	mount_md 4096 /dev 3 512
8483221Smarcel	(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
8583221Smarcelfi
8668583Smarcel