summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/var
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2002-12-22 22:18:41 +0000
committerdillon <dillon@FreeBSD.org>2002-12-22 22:18:41 +0000
commit59db35bde2503abe71cac5a91acaedd768348893 (patch)
tree7a4959cdbe6bcce1760e14e20b92457e482609c6 /etc/rc.d/var
parentf2916da2791f333ec0f2f358bf35929a351bd2e0 (diff)
downloadFreeBSD-src-59db35bde2503abe71cac5a91acaedd768348893.zip
FreeBSD-src-59db35bde2503abe71cac5a91acaedd768348893.tar.gz
Do not unconditionally load the configuration files for the RCNG case.
Instead, load them as part of the rc.d system. This allows us to prioritize the initidiskless script so it runs before the configuration files are loaded and allows us to get rid of the exit 2 hack in /etc/rc. The exit 2 never worked anyway since it did not unset the prior configuration, causing the diskless code to not operate properly. Do a major cleanup and revamping of the diskless code for RCNG. This will be backported to the non-RCNG scripts as well as -stable. With suggestions from: Mike Makonnen <mtm@identd.net> MFC after: 7 days
Diffstat (limited to 'etc/rc.d/var')
-rw-r--r--etc/rc.d/var108
1 files changed, 77 insertions, 31 deletions
diff --git a/etc/rc.d/var b/etc/rc.d/var
index 647e3b7..e74d0bd 100644
--- a/etc/rc.d/var
+++ b/etc/rc.d/var
@@ -28,7 +28,7 @@
#
# PROVIDE: diskless
-# REQUIRE: initdiskless mountcritlocal
+# REQUIRE: initdiskless rcconf mountcritlocal
# BEFORE: addswap random
# KEYWORD: FreeBSD
@@ -42,14 +42,12 @@ name="diskless2"
# as close as possible between 5-current and 4-stable.
# $1 = size
# $2 = mount point
-# $3 = md unit number (ignored in pre 5.0 systems)
-# $4 = (optional) bytes-per-inode
-mount_md()
-{
- if [ -n "$4" ]; then
- bpi="-i $4"
+# $3 = (optional) bytes-per-inode
+mount_md() {
+ if [ -n "$3" ]; then
+ bpi="-i $3"
fi
- /sbin/mdmfs $bpi -s $1 -M md$3 $2
+ /sbin/mdmfs $bpi -s $1 -M md $2
}
# If there is a global system configuration file, suck it in.
@@ -64,16 +62,36 @@ elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
-echo "+++ mount_md of /var"
-mount_md ${varsize:=32m} /var 1
+# 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
+/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 /
+ /usr/sbin/mtree -deU -f /etc/mtree/BSD.sendmail.dist -p / > /dev/null
;;
esac
@@ -86,34 +104,62 @@ fi
echo "+++ create lastlog"
/usr/bin/touch /var/log/lastlog
-mount -a # chown and chgrp are in /usr
-
-# Since we are starting with a very fresh /etc on an MFS:
-if [ -d /conf/default/etc ]; then
- newaliases
-fi
-
-#
-# XXX make sure to create one dir for each printer as requested by lpd
+# Make sure our aliases database is uptodate, the aliases may have
+# been overriden in /conf.
#
+/usr/bin/newaliases
-# If /tmp is a symlink, assume it points to somewhere writable, like
-# /var/tmp, otherwise, use a small memory filesystem for /tmp.
+# XXX make sure to create one dir for each printer as requested by lpd
#
-# XXX: mtree runs too early to create any directories needed in /tmp,
-# so if /var/tmp == /tmp, then you don't get a vi.recover.
+# 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 [ ! -L /tmp ]; then
- mount_md ${tmpsize:=64m} /tmp 2
- chmod 01777 /tmp
+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
+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 rc.diskless1
+ #
+ rmdir /dev/.diskless
else
- # extract a list of device entries, then copy them to a writable fs
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
- mount_md 4096 /dev 3 512
+ 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`" ]; then
+ hostname=`/usr/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 ]; then
+ echo domain `/usr/bin/kenv dhcp.domain-name` > /etc/resolv.conf
+
+ set `/usr/bin/kenv dhcp.domain-name-servers`
+ for ns in `IFS=','; echo $*`; do
+ echo nameserver $ns >> /etc/resolv.conf;
+ done
+fi
+
OpenPOWER on IntegriCloud