tmp revision 91074
1#!/bin/sh 2# 3# Copyright (c) 1999 Matt Dillon 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# $FreeBSD: head/etc/rc.d/tmp 91074 2002-02-22 19:05:22Z obrien $ 26# 27# $FreeBSD: head/etc/rc.d/tmp 91074 2002-02-22 19:05:22Z obrien $ 28# 29 30# PROVIDE: diskless 31# REQUIRE: initdiskless mountcritlocal 32# BEFORE: addswap random 33# KEYWORD: FreeBSD 34 35dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 36[ ${dlv:=0} -eq 0 ] && exit 0 37 38name="diskless2" 39 40# Provide a function for normalizing the mounting of memory 41# filesystems. This should allow the rest of the code here to remain 42# as close as possible between 5-current and 4-stable. 43# $1 = size 44# $2 = mount point 45# $3 = md unit number (ignored in pre 5.0 systems) 46# $4 = (optional) bytes-per-inode 47mount_md() 48{ 49 if [ -n "$4" ]; then 50 bpi="-i $4" 51 fi 52 /sbin/mdconfig -a -t malloc -s $1 -u $3 53 /sbin/disklabel -r -w md$3 auto 54 /sbin/newfs $bpi /dev/md$3c 55 /sbin/mount /dev/md$3c $2 56} 57 58# If there is a global system configuration file, suck it in. 59# 60if [ -r /etc/rc.subr ]; then 61 . /etc/rc.subr 62 load_rc_config $name 63echo "+++ mount_md of /var" 64mount_md ${varsize:=32m} /var 1 65 66echo "+++ populate /var using /etc/mtree/BSD.var.dist" 67/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var 68case ${sendmail_enable} in 69echo "+++ create log files based on the contents of /etc/newsyslog.conf" 70LOGFILES=`/usr/bin/awk '$1 != "#" { printf "%s ", $1 } ' /etc/newsyslog.conf` 71if [ -n "$LOGFILES" ]; then 72 /usr/bin/touch $LOGFILES 73fi 74 75# Since we are starting with a very fresh /etc on an MFS: 76if [ -d /conf/default/etc ]; then 77 newaliases 78fi 79 80# 81# XXX make sure to create one dir for each printer as requested by lpd 82# 83 84# If /tmp is a symlink, assume it points to somewhere writable, like 85# /var/tmp, otherwise, use a small memory filesystem for /tmp. 86# 87# XXX: mtree runs too early to create any directories needed in /tmp, 88# so if /var/tmp == /tmp, then you don't get a vi.recover. 89# 90if [ ! -h /tmp ]; then 91 mount_md ${tmpsize:=64m} /tmp 2 92 chmod 01777 /tmp 93fi 94 95if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then 96 # we have DEVFS, no worries... 97 true 98else 99 # extract a list of device entries, then copy them to a writable fs 100 (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp 101 mount_md 4096 /dev 3 512 102 (cd /; cpio -i -H newc -d < /tmp/dev.tmp) 103fi 104