Overhaul the /etc/rc.d/diskless script by splitting it out into

hostname, resolve, tmp, and var scripts.  The latter three are new and
were repo copied.  These scripts no longer depend on being booted with
and NFS root instead attempt to automaticly create mfs /tmp and /var
volumes if the they are not writable.  This behavior can be overridden
in /etc/rc.conf.

Reviewed by:    luigi, pjd
This commit is contained in:
Brooks Davis 2004-03-23 23:22:35 +00:00
parent 62b7be1be9
commit 3e091039ee
11 changed files with 167 additions and 573 deletions

View File

@ -38,6 +38,11 @@ pccardd_flags="-z" # Additional flags for pccardd.
pccard_conf="/etc/defaults/pccard.conf" # pccardd(8) config file pccard_conf="/etc/defaults/pccard.conf" # pccardd(8) config file
pccard_ether_delay="5" # Delay before trying to start dhclient in pccard_ether pccard_ether_delay="5" # Delay before trying to start dhclient in pccard_ether
removable_interfaces="" # Removable network interfaces for /etc/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. 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 script_name_sep=" " # Change if your startup scripts' names contain spaces
rc_conf_files="/etc/rc.conf /etc/rc.conf.local" rc_conf_files="/etc/rc.conf /etc/rc.conf.local"

View File

@ -6,7 +6,7 @@ FILES= DAEMON LOGIN NETWORKING SERVERS \
apm apmd archdep atm1 atm2 atm3 \ apm apmd archdep atm1 atm2 atm3 \
bgfsck bootparams \ bgfsck bootparams \
ccd cleanvar cleartmp cron \ ccd cleanvar cleartmp cron \
devd devfs dhclient diskless \ devd devfs dhclient \
dmesg dumpon \ dmesg dumpon \
early.sh \ early.sh \
fsck \ fsck \
@ -27,14 +27,14 @@ FILES= DAEMON LOGIN NETWORKING SERVERS \
othermta \ othermta \
pccard pcvt power_profile ppp-user pppoed pwcheck \ pccard pcvt power_profile ppp-user pppoed pwcheck \
quota \ quota \
random rarpd rcconf.sh root \ random rarpd rcconf.sh resolv root \
route6d routed routing rpcbind rtadvd rwho \ route6d routed routing rpcbind rtadvd rwho \
savecore securelevel sendmail \ savecore securelevel sendmail \
serial sppp sshd swap1 \ serial sppp sshd swap1 \
syscons sysctl syslogd \ syscons sysctl syslogd \
timed \ timed tmp \
usbd \ usbd \
vinum virecover \ var vinum virecover \
watchdogd \ watchdogd \
ypbind yppasswdd ypserv \ ypbind yppasswdd ypserv \
ypset ypupdated ypxfrd ypset ypupdated ypxfrd

View File

@ -4,7 +4,7 @@
# #
# PROVIDE: cleanvar # PROVIDE: cleanvar
# REQUIRE: mountcritlocal # REQUIRE: mountcritlocal var
# KEYWORD: FreeBSD # KEYWORD: FreeBSD
purgedir() purgedir()

View File

@ -5,7 +5,7 @@
# #
# PROVIDE: cleartmp # PROVIDE: cleartmp
# REQUIRE: mountcritremote # REQUIRE: mountcritremote tmp
# BEFORE: DAEMON # BEFORE: DAEMON
# KEYWORD: FreeBSD # KEYWORD: FreeBSD

View File

@ -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

View File

@ -49,6 +49,14 @@ hostname_start()
fi fi
elif [ -n "`hostname -s`" ]; then elif [ -n "`hostname -s`" ]; then
return 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 fi
hostname ${hostname} hostname ${hostname}

View File

@ -27,143 +27,26 @@
# $FreeBSD$ # $FreeBSD$
# #
# PROVIDE: diskless # PROVIDE: resolv
# REQUIRE: initdiskless rcconf mountcritlocal # REQUIRE: initdiskless rcconf
# BEFORE: addswap random
# KEYWORD: FreeBSD nojail # KEYWORD: FreeBSD nojail
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` . /etc/rc.subr
[ ${dlv:=0} -eq 0 ] && exit 0
name="diskless2" name="resolv"
# Provide a function for normalizing the mounting of memory load_rc_config $name
# 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 # if the info is available via dhcp/kenv
# build the resolv.conf # build the resolv.conf
# #
if [ ! -e /etc/resolv.conf -a \ if [ ! -e /etc/resolv.conf -a \
"x`/bin/kenv dhcp.domain-name-servers`" != "x" ]; then -n "`/bin/kenv dhcp.domain-name-servers 2> /dev/null`" ]; then
echo domain `/bin/kenv dhcp.domain-name` > /etc/resolv.conf /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` set `/bin/kenv dhcp.domain-name-servers`
for ns in `IFS=','; echo $*`; do for ns in `IFS=','; echo $*`; do

View File

@ -27,147 +27,39 @@
# $FreeBSD$ # $FreeBSD$
# #
# PROVIDE: diskless # PROVIDE: tmp
# REQUIRE: initdiskless rcconf mountcritlocal # REQUIRE: mountcritlocal
# BEFORE: addswap random # KEYWORD: FreeBSD
# KEYWORD: FreeBSD nojail
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` . /etc/rc.subr
[ ${dlv:=0} -eq 0 ] && exit 0
name="diskless2" name="tmp"
# Provide a function for normalizing the mounting of memory load_rc_config $name
# 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 # If we do not have a writable /tmp, create a memory
# filesystem for /tmp. If /tmp is a symlink (e.g. to /var/tmp, # filesystem for /tmp. If /tmp is a symlink (e.g. to /var/tmp,
# then it should already be writable). # then it should already be writable).
# #
if (/bin/mkdir /tmp/.diskless 2> /dev/null); then case "${tmpmfs}" in
rmdir /tmp/.diskless [Yy][Ee][Ss])
else mount_md ${tmpsize} /tmp
if [ -h /tmp ]; then chmod 01777 /tmp
echo "*** /tmp is a symlink to a non-writable area!" ;;
echo "dropping into shell, ^D to continue anyway." [Nn][Oo])
/bin/sh ;;
*)
if (/bin/mkdir /tmp/.diskless 2> /dev/null); then
rmdir /tmp/.diskless
else else
mount_md ${tmpsize:=20480} /tmp if [ -h /tmp ]; then
chmod 01777 /tmp 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
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

View File

@ -27,147 +27,71 @@
# $FreeBSD$ # $FreeBSD$
# #
# PROVIDE: diskless # PROVIDE: var
# REQUIRE: initdiskless rcconf mountcritlocal # REQUIRE: mountcritlocal
# BEFORE: addswap random # KEYWORD: FreeBSD
# KEYWORD: FreeBSD nojail
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` . /etc/rc.subr
[ ${dlv:=0} -eq 0 ] && exit 0
name="diskless2" name="var"
# Provide a function for normalizing the mounting of memory load_rc_config $name
# filesystems. This should allow the rest of the code here to remain
# as close as possible between 5-current and 4-stable. _populate_var()
# $1 = size {
# $2 = mount point /usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var > /dev/null
# $3 = (optional) bytes-per-inode case ${sendmail_enable} in
mount_md() { [Nn][Oo][Nn][Ee])
if [ -n "$3" ]; then ;;
bpi="-i $3" *)
fi /usr/sbin/mtree -deU -f /etc/mtree/BSD.sendmail.dist -p / > /dev/null
/sbin/mdmfs $bpi -s $1 -M md $2 ;;
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 case "${varmfs}" in
. /etc/rc.subr [Yy][Ee][Ss])
load_rc_config $name mount_md ${varsize} /var
elif [ -r /etc/defaults/rc.conf ]; then ;;
. /etc/defaults/rc.conf [Nn][Oo])
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 if (/bin/mkdir /var/.diskless 2> /dev/null); then
;; rmdir /var/.diskless
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 else
mount_md ${tmpsize:=20480} /tmp mount_md ${varsize} /var
chmod 01777 /tmp
fi 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

View File

@ -1273,3 +1273,16 @@ devfs_mount_jail()
fi fi
return 0 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
}

View File

@ -225,6 +225,48 @@ based cards.
.Pq Vt str .Pq Vt str
List of removable network interfaces to be supported by List of removable network interfaces to be supported by
.Pa /etc/pccard_ether . .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 .It Va local_startup
.Pq Vt str .Pq Vt str
List of directories to search for startup script files. List of directories to search for startup script files.