summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/initdiskless
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2000-01-06 18:17:38 +0000
committerluigi <luigi@FreeBSD.org>2000-01-06 18:17:38 +0000
commita924d4cf00576f674fb2ea1d40a5f7011f7ec128 (patch)
treef32a17c80f0d266631db3ff9b776980765ef0e52 /etc/rc.d/initdiskless
parentd8b8a4a2a7b05714878e3ad14fd527346f28f443 (diff)
downloadFreeBSD-src-a924d4cf00576f674fb2ea1d40a5f7011f7ec128.zip
FreeBSD-src-a924d4cf00576f674fb2ea1d40a5f7011f7ec128.tar.gz
Cleanup diskless support in current, mostly aligning it to the one
in the 3.x branch. Also remove the dependency on /usr to find the boot address/interface. Mostly-submitted-abd-tested-by: MIHIRA Sanpei Yoshiro <sanpei@sanpei.org>
Diffstat (limited to 'etc/rc.d/initdiskless')
-rw-r--r--etc/rc.d/initdiskless107
1 files changed, 52 insertions, 55 deletions
diff --git a/etc/rc.d/initdiskless b/etc/rc.d/initdiskless
index 4679a28..6b306ba 100644
--- a/etc/rc.d/initdiskless
+++ b/etc/rc.d/initdiskless
@@ -1,24 +1,20 @@
# $FreeBSD$
#
-# /etc/rc.diskless - general BOOTP startup
+# /etc/rc.diskless1 - general BOOTP startup
#
-# BOOTP has mounted / for us. Assume a read-only mount. We must then
-# - figure out where the NFS mount is coming from
-# - figure out our IP by querying the interface
-# - retarget /conf/ME softlink to proper configuration script directory
+# BOOTP has mounted / for us. Assume a read-only mount. We must then
+# - figure out our IP by querying the interface
+# - fill /conf/etc (writable) with files from /etc, and then update
+# per-machine files from /conf/*/ where * is the IP of the host,
+# the IP of the subnet, "default", or nothing.
+# - mount /conf/etc over /etc so we can see the new files.
#
-# It is expected that /etc/fstab and /etc/rc.conf.local will be
-# set by the system operator on the server to be softlinks to
-# /conf/ME/fstab and /conf/ME/rc.conf.local. The system operator may
-# choose to retarget other files as well. The server itself boots
-# properly with its default /conf/ME softlink pointing to
-# /conf/server.host.name.
+# WARNING: i thing you should not change /etc/rc or strange things could
+# happen.
#
-# During a diskless boot, we retarget the /conf/ME softlink to point
-# to /conf/DISKLESS.CLIENT.IP.ADDRESS. Thus, various system config
-# files that are softlinks through /conf/ME also get retargeted.
-#
-# SEE SAMPLE FILES IN /usr/share/examples/diskless.
+# The operator is in charge of setting /conf/*/etc/* things as appropriate.
+# Typically rc.conf and fstab need to be changed, but possibly
+# also other files such as inetd.conf etc.
# chkerr:
#
@@ -41,55 +37,56 @@ chkerr() {
# DEBUGGING
#
-set -v
-
-# Figure out where the root mount is coming from, synthesize a mount
-# for /usr and mount it.
-#
-# e.g. nfs_root might wind up as "A.B.C.D:/"
-#
-# NOTE! the /usr mount is only temporary so we can access commands necessary
-# to retarget /conf/ME. The actual /usr mount should be part of the
-# retargeted /etc/fstab. See instructions in /usr/share/examples/diskless.
-#
-set `/bin/df /`
-nfs_root=$8
-mount_nfs -o ro ${nfs_root}/usr /usr
-
-chkerr $? "mount of /usr"
+# set -v
# Figure out our interface and IP.
#
-
-bootp_ifc=`route -n get default | fgrep interface | awk '{ print $2; }'`
-bootp_ipa=`ifconfig ${bootp_ifc} | fgrep inet | head -1 | awk '{ print $2; }'`
-
-echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa}"
-
-umount /usr
-
-# retarget /conf/ME
-#
-# MFS's background process takes a bit to startup. Various config files
-# on server should be softlinks through /conf/ME. The server's own /conf/ME
-# points to the server's version of the files.
-#
-# We retarget /conf/ME using a -o union mount. This allows
-# us to 'mkdir' over whatever was there previously.
+bootp_ifc=""
+bootp_ipa=""
+bootp_ipbca=""
+iflist=`ifconfig -l`
+for i in ${iflist} ; do
+ set `ifconfig ${i}`
+ while [ $# -ge 1 ] ; do
+ if [ "${bootp_ifc}" = "" -a "$1" = "inet" ] ; then
+ bootp_ifc=${i} ; bootp_ipa=${2} ; shift
+ fi
+ if [ "${bootp_ipbca}" = "" -a "$1" = "broadcast" ] ; then
+ bootp_ipbca=$2; shift
+ fi
+ shift
+ done
+ if [ "${bootp_ifc}" != "" ] ; then
+ break
+ fi
+done
+echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}"
+
+# Files in /etc are copied to /conf/etc which is writable. Then
+# per-machine configs from /conf/ip.address/etc are copied onto this
+# directory. First choice is using the client's IP, then the client's
+# broadcast address, then a default configuration.
+# This way we have some flexibility to handle clusters of machines
+# on separate subnets.
#
# WARNING! null mounts cannot handle mmap, and since many programs
# use mmap (such as 'cp'), we have to copy.
#
-mount_mfs -s 256 -T qp120at -o union dummy /conf
-chkerr $? "MFS mount on /conf"
+mount_mfs -s 2048 -T qp120at dummy /conf/etc
+cp -Rp /etc/* /conf/etc
+chkerr $? "MFS mount on /conf/etc"
-mkdir /conf/ME
-cp -Rp /conf/$bootp_ipa/* /conf/ME
+if [ -d /conf/${bootp_ipa} ] ; then
+ cp -Rp /conf/${bootp_ipa}/etc/* /conf/etc
+elif [ -d /conf/${bootp_ipbca} ] ; then
+ cp -Rp /conf/${bootp_ipbca}/etc/* /conf/etc
+else
+ cp -Rp /conf/default/etc/* /conf/etc
+fi
-# retarget the kernel
+# Make the new directory available as /etc
#
-
-sysctl -w kern.bootfile=/conf/ME/kernel
+mount_null /conf/etc /etc
# Tell /etc/rc to run the specified script after
# it does its mounts but before it does anything
OpenPOWER on IntegriCloud