tmp revision 87010
1220163Strasz#!/bin/sh 2220163Strasz# 3220163Strasz# Copyright (c) 1999 Matt Dillon 4220163Strasz# All rights reserved. 5220163Strasz# 6220163Strasz# Redistribution and use in source and binary forms, with or without 7220163Strasz# modification, are permitted provided that the following conditions 8220163Strasz# are met: 9220163Strasz# 1. Redistributions of source code must retain the above copyright 10220163Strasz# notice, this list of conditions and the following disclaimer. 11220163Strasz# 2. Redistributions in binary form must reproduce the above copyright 12220163Strasz# notice, this list of conditions and the following disclaimer in the 13220163Strasz# documentation and/or other materials provided with the distribution. 14220163Strasz# 15220163Strasz# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16220163Strasz# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17220163Strasz# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18220163Strasz# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19220163Strasz# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20220163Strasz# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21220163Strasz# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22220163Strasz# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23220163Strasz# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24220163Strasz# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25220163Strasz# $FreeBSD: head/etc/rc.d/tmp 87010 2001-11-27 22:12:27Z rwatson $ 26220163Strasz# 27220163Strasz# $FreeBSD: head/etc/rc.d/tmp 87010 2001-11-27 22:12:27Z rwatson $ 28220163Strasz# 29220163Strasz 30220163Strasz# PROVIDE: diskless 31220163Strasz# REQUIRE: initdiskless mountcritlocal 32220163Strasz# BEFORE: addswap random 33220163Strasz# KEYWORD: FreeBSD 34220163Strasz 35220163Straszdlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 36220163Strasz[ ${dlv:=0} -eq 0 ] && exit 0 37220163Strasz 38220163Straszname="diskless2" 39220163Strasz 40220163Strasz# Provide a function for normalizing the mounting of memory 41220163Strasz# filesystems. This should allow the rest of the code here to remain 42220163Strasz# as close as possible between 5-current and 4-stable. 43220163Strasz# $1 = size 44220163Strasz# $2 = mount point 45220163Strasz# $3 = md unit number (ignored in pre 5.0 systems) 46220163Strasz# $4 = (optional) bytes-per-inode 47220163Straszmount_md() 48220163Strasz{ 49220163Strasz if [ -n "$4" ]; then 50220163Strasz bpi="-i $4" 51220163Strasz fi 52220163Strasz /sbin/mdconfig -a -t malloc -s $1 -u $3 53220163Strasz /sbin/disklabel -r -w md$3 auto 54220163Strasz /sbin/newfs $bpi /dev/md$3c 55220163Strasz /sbin/mount /dev/md$3c $2 56220163Strasz} 57220163Strasz 58220163Strasz# If there is a global system configuration file, suck it in. 59220163Straszmount_md ${varsize:=65536} /var 1 60220163Straszif [ -r /etc/rc.subr ]; then 61220163Strasz . /etc/rc.subr 62220163Strasz load_rc_config $name 63220163Straszecho "+++ mount_md of /var" 64220163Straszmount_md ${varsize:=32m} /var 1 65220163Strasz 66220163Straszecho "+++ populate /var using /etc/mtree/BSD.var.dist" 67220163Strasz/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var 68220163Straszcase ${sendmail_enable} in 69220163Straszecho "+++ create log files based on the contents of /etc/newsyslog.conf" 70220163StraszLOGFILES=`/usr/bin/awk '$1 != "#" { printf "%s ", $1 } ' /etc/newsyslog.conf` 71220163Straszif [ -n "$LOGFILES" ]; then 72220163Strasz /usr/bin/touch $LOGFILES 73220163Straszfi 74220163Strasz 75220163Strasz# Since we are starting with a very fresh /etc on an MFS: 76220163Straszif [ -d /conf/default/etc ]; then 77220163Strasz newaliases 78220163Straszfi 79220163Strasz 80220163Strasz# 81220163Strasz# /var/tmp, otherwise, use a small memory filesystem for /tmp. 82220163Strasz mount_md ${tmpsize:=20480} /tmp 2 83220163Strasz# XXX: mtree runs too early to create any directories needed in /tmp, 84220163Strasz# so if /var/tmp == /tmp, then you don't get a vi.recover. 85220163Strasz# 86220163Straszif [ ! -h /tmp ]; then 87220163Strasz mount_md ${tmpsize:=64m} /tmp 2 88220163Strasz chmod 01777 /tmp 89220163Straszfi 90220163Strasz 91220163Straszif sysctl vfs.devfs.generation > /dev/null 2>&1 ; then 92220163Strasz # we have DEVFS, no worries... 93220163Strasz true 94220163Straszelse 95220163Strasz # extract a list of device entries, then copy them to a writable fs 96220163Strasz (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp 97220163Strasz mount_md 4096 /dev 3 512 98220163Strasz (cd /; cpio -i -H newc -d < /tmp/dev.tmp) 99220163Straszfi 100220163Strasz