diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index 884f63cef784..b6088589b755 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -38,6 +38,11 @@ pccardd_flags="-z" # Additional flags for pccardd. pccard_conf="/etc/defaults/pccard.conf" # pccardd(8) config file pccard_ether_delay="5" # Delay before trying to start dhclient in pccard_ether removable_interfaces="" # Removable network interfaces for /etc/pccard_ether. +tmpmfs="AUTO" # Set to YES to always create an mfs /tmp, NO to never +tmpsize="20m" # Size of mfs /tmp if created +varmfs="AUTO" # Set to YES to always create an mfs /var, NO to never +varsize="32m" # Size of mfs /var if created +populate_var="AUTO" # Set to YES to always (re)populate /var, NO to never local_startup="/usr/local/etc/rc.d /usr/X11R6/etc/rc.d" # startup script dirs. script_name_sep=" " # Change if your startup scripts' names contain spaces rc_conf_files="/etc/rc.conf /etc/rc.conf.local" diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index 2f44a1311cb4..9cd5272373ec 100755 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -6,7 +6,7 @@ FILES= DAEMON LOGIN NETWORKING SERVERS \ apm apmd archdep atm1 atm2 atm3 \ bgfsck bootparams \ ccd cleanvar cleartmp cron \ - devd devfs dhclient diskless \ + devd devfs dhclient \ dmesg dumpon \ early.sh \ fsck \ @@ -27,14 +27,14 @@ FILES= DAEMON LOGIN NETWORKING SERVERS \ othermta \ pccard pcvt power_profile ppp-user pppoed pwcheck \ quota \ - random rarpd rcconf.sh root \ + random rarpd rcconf.sh resolv root \ route6d routed routing rpcbind rtadvd rwho \ savecore securelevel sendmail \ serial sppp sshd swap1 \ syscons sysctl syslogd \ - timed \ + timed tmp \ usbd \ - vinum virecover \ + var vinum virecover \ watchdogd \ ypbind yppasswdd ypserv \ ypset ypupdated ypxfrd diff --git a/etc/rc.d/cleanvar b/etc/rc.d/cleanvar index 315cf54e59cf..d1864b71ed17 100644 --- a/etc/rc.d/cleanvar +++ b/etc/rc.d/cleanvar @@ -4,7 +4,7 @@ # # PROVIDE: cleanvar -# REQUIRE: mountcritlocal +# REQUIRE: mountcritlocal var # KEYWORD: FreeBSD purgedir() diff --git a/etc/rc.d/cleartmp b/etc/rc.d/cleartmp index 2879f8f11b4a..92b47e386e3c 100755 --- a/etc/rc.d/cleartmp +++ b/etc/rc.d/cleartmp @@ -5,7 +5,7 @@ # # PROVIDE: cleartmp -# REQUIRE: mountcritremote +# REQUIRE: mountcritremote tmp # BEFORE: DAEMON # KEYWORD: FreeBSD diff --git a/etc/rc.d/diskless b/etc/rc.d/diskless deleted file mode 100644 index b2a81543dd32..000000000000 --- a/etc/rc.d/diskless +++ /dev/null @@ -1,173 +0,0 @@ -#!/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$ -# - -# 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 - diff --git a/etc/rc.d/hostname b/etc/rc.d/hostname index f740cde80e84..65b6ba2435fe 100644 --- a/etc/rc.d/hostname +++ b/etc/rc.d/hostname @@ -49,6 +49,14 @@ hostname_start() fi elif [ -n "`hostname -s`" ]; then return + else + # If we're not in a jail and rc.conf doesn't specify a + # hostname, see if we can get one from kenv. + # + if [ -z "${hostname}" -a \ + -n "`/bin/kenv dhcp.host-name 2> /dev/null`" ]; then + hostname=`/bin/kenv dhcp.host-name` + fi fi hostname ${hostname} diff --git a/etc/rc.d/resolv b/etc/rc.d/resolv index b2a81543dd32..84837f92abcd 100644 --- a/etc/rc.d/resolv +++ b/etc/rc.d/resolv @@ -27,143 +27,26 @@ # $FreeBSD$ # -# PROVIDE: diskless -# REQUIRE: initdiskless rcconf mountcritlocal -# BEFORE: addswap random +# PROVIDE: resolv +# REQUIRE: initdiskless rcconf # KEYWORD: FreeBSD nojail -dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` -[ ${dlv:=0} -eq 0 ] && exit 0 +. /etc/rc.subr -name="diskless2" +name="resolv" -# 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 +load_rc_config $name # 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 + -n "`/bin/kenv dhcp.domain-name-servers 2> /dev/null`" ]; then + /bin/cat /dev/null > /etc/resolv.conf + + if [ -n "`/bin/kenv dhcp.domain-name 2> /dev/null`" ]; then + echo domain `/bin/kenv dhcp.domain-name` > /etc/resolv.conf + fi set `/bin/kenv dhcp.domain-name-servers` for ns in `IFS=','; echo $*`; do diff --git a/etc/rc.d/tmp b/etc/rc.d/tmp index b2a81543dd32..26cc64a90bc1 100644 --- a/etc/rc.d/tmp +++ b/etc/rc.d/tmp @@ -27,147 +27,39 @@ # $FreeBSD$ # -# PROVIDE: diskless -# REQUIRE: initdiskless rcconf mountcritlocal -# BEFORE: addswap random -# KEYWORD: FreeBSD nojail +# PROVIDE: tmp +# REQUIRE: mountcritlocal +# KEYWORD: FreeBSD -dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` -[ ${dlv:=0} -eq 0 ] && exit 0 +. /etc/rc.subr -name="diskless2" +name="tmp" -# 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 -} +load_rc_config $name -# 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 +case "${tmpmfs}" in +[Yy][Ee][Ss]) + mount_md ${tmpsize} /tmp + chmod 01777 /tmp + ;; +[Nn][Oo]) + ;; +*) + if (/bin/mkdir /tmp/.diskless 2> /dev/null); then + rmdir /tmp/.diskless else - mount_md ${tmpsize:=20480} /tmp - chmod 01777 /tmp + 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} /tmp + chmod 01777 /tmp + fi 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 - + ;; +esac diff --git a/etc/rc.d/var b/etc/rc.d/var index b2a81543dd32..38108ad949f5 100644 --- a/etc/rc.d/var +++ b/etc/rc.d/var @@ -27,147 +27,71 @@ # $FreeBSD$ # -# PROVIDE: diskless -# REQUIRE: initdiskless rcconf mountcritlocal -# BEFORE: addswap random -# KEYWORD: FreeBSD nojail +# PROVIDE: var +# REQUIRE: mountcritlocal +# KEYWORD: FreeBSD -dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` -[ ${dlv:=0} -eq 0 ] && exit 0 +. /etc/rc.subr -name="diskless2" +name="var" -# 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 +load_rc_config $name + +_populate_var() +{ + /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 + + /usr/sbin/newsyslog -CC + + /usr/bin/touch /var/log/lastlog + + # XXX: should create spool dirs for lpd } -# If there is a global system configuration file, suck it in. +# If we do not have a writable /var, create a memory filesystem for /var +# unless told otherwise by rc.conf. 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 [ -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]) +case "${varmfs}" in +[Yy][Ee][Ss]) + mount_md ${varsize} /var + ;; +[Nn][Oo]) ;; *) - /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 + if (/bin/mkdir /var/.diskless 2> /dev/null); then + rmdir /var/.diskless else - mount_md ${tmpsize:=20480} /tmp - chmod 01777 /tmp + mount_md ${varsize} /var fi -fi +esac -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 +# If we have an empty looking /var, populate it, but only if we have +# /usr available. Hopefully, we'll eventually find a workaround, but +# in realistic diskless setups, we're probably ok. +case "${populate_var}" in +[Yy][Ee][Ss]) + _populate_var + ;; +[Nn][Oo]) + ;; +*) + if [ -d /var/run -a -d /var/db -a -d /var/empty ] ; then + true + elif [ ! -x /usr/sbin/mtree -o ! -x /usr/sbin/newsyslog -o \ + ! -x /usr/bin/touch ] ; then + false + else + _populate_var + fi + ;; +esac diff --git a/etc/rc.subr b/etc/rc.subr index 9830ec86ac88..74784b95af9d 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -1273,3 +1273,16 @@ devfs_mount_jail() fi return 0 } + +# 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 +} diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 7f7c69563f49..accb2b7c894a 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -225,6 +225,48 @@ based cards. .Pq Vt str List of removable network interfaces to be supported by .Pa /etc/pccard_ether . +.It Va tmpmfs +Controls the creation of an mfs +.Pa /tmp +file system. +Always happens if set to +.Dq Li YES +and never happens if set to +.Dq Li NO . +If set anything else, a memory file system is created if +.Pa /tmp +is not writable. +.It Va tmpsize +Controls the size of a created mfm +.Pa /tmp . +.It Va varmfs +Controls the creation of an mfs +.Pa /var +file system. +Always happens if set to +.Dq Li YES +and never happens if set to +.Dq Li NO . +If set anything else, a memory file system is created if +.Pa /var +is not writable. +.It Va varsize +Controls the size of a created mfm +.Pa /var . +.It Va populate_var +Controls the automatic population of the +.Pa /var +file system. +Always happens if set to +.Dq Li YES +and never happens if set to +.Dq Li NO . +If set anything else, a memory file system is created if /tmp is not writable. +Note that this process requires access to certain commands in +.Pa /usr +before +.Pa /usr +is mounted on normal systems. .It Va local_startup .Pq Vt str List of directories to search for startup script files.