2000-10-08 19:20:36 +00:00
|
|
|
# Copyright (c) 1999 Matt Dillion
|
|
|
|
# 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.
|
|
|
|
#
|
1999-09-13 15:44:20 +00:00
|
|
|
# $FreeBSD$
|
2000-10-08 19:20:36 +00:00
|
|
|
#
|
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
#
|
2000-01-06 18:17:38 +00:00
|
|
|
# /etc/rc.diskless1 - general BOOTP startup
|
1999-02-09 17:17:18 +00:00
|
|
|
#
|
2000-01-06 18:17:38 +00:00
|
|
|
# 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.
|
1999-02-09 17:17:18 +00:00
|
|
|
#
|
2000-01-06 18:17:38 +00:00
|
|
|
# WARNING: i thing you should not change /etc/rc or strange things could
|
|
|
|
# happen.
|
1999-02-09 17:17:18 +00:00
|
|
|
#
|
2000-01-06 18:17:38 +00:00
|
|
|
# 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.
|
1999-02-09 17:17:18 +00:00
|
|
|
|
|
|
|
# chkerr:
|
|
|
|
#
|
|
|
|
# Routine to check for error
|
|
|
|
#
|
|
|
|
# checks error code and drops into shell on failure.
|
|
|
|
# if shell exits, terminates script as well as /etc/rc.
|
1999-09-13 15:44:20 +00:00
|
|
|
#
|
1999-02-09 17:17:18 +00:00
|
|
|
chkerr() {
|
1999-09-13 15:44:20 +00:00
|
|
|
case $1 in
|
|
|
|
0)
|
|
|
|
;;
|
|
|
|
*)
|
1999-02-09 17:17:18 +00:00
|
|
|
echo "$2 failed: dropping into /bin/sh"
|
|
|
|
/bin/sh
|
|
|
|
# RESUME
|
1999-09-13 15:44:20 +00:00
|
|
|
;;
|
|
|
|
esac
|
1999-02-09 17:17:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# DEBUGGING
|
|
|
|
#
|
2000-01-06 18:17:38 +00:00
|
|
|
# set -v
|
1999-02-09 17:17:18 +00:00
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
# Figure out our interface and IP.
|
1999-02-09 17:17:18 +00:00
|
|
|
#
|
2000-01-06 18:17:38 +00:00
|
|
|
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.
|
1999-02-09 17:17:18 +00:00
|
|
|
#
|
|
|
|
# WARNING! null mounts cannot handle mmap, and since many programs
|
|
|
|
# use mmap (such as 'cp'), we have to copy.
|
1999-09-13 15:44:20 +00:00
|
|
|
#
|
2000-01-06 18:17:38 +00:00
|
|
|
mount_mfs -s 2048 -T qp120at dummy /conf/etc
|
|
|
|
cp -Rp /etc/* /conf/etc
|
|
|
|
chkerr $? "MFS mount on /conf/etc"
|
1999-02-09 17:17:18 +00:00
|
|
|
|
2001-04-03 00:24:01 +00:00
|
|
|
# Pick up default, network-specific, and host-specific config, in that
|
|
|
|
# order
|
|
|
|
|
|
|
|
if [ -d /conf/default/etc/ ]; then
|
|
|
|
cp -Rp /conf/default/etc/* /conf/etc
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d /conf/${bootp_ipbca} ] ; then
|
|
|
|
cp -Rp /conf/${bootp_ipbca}/etc/* /conf/etc
|
|
|
|
fi
|
|
|
|
|
2000-01-06 18:17:38 +00:00
|
|
|
if [ -d /conf/${bootp_ipa} ] ; then
|
2001-04-03 00:24:01 +00:00
|
|
|
cp -Rp /conf/${bootp_ipa}/etc/* /conf/etc
|
2000-01-06 18:17:38 +00:00
|
|
|
fi
|
1999-02-09 17:17:18 +00:00
|
|
|
|
2000-01-06 18:17:38 +00:00
|
|
|
# Make the new directory available as /etc
|
1999-02-09 17:17:18 +00:00
|
|
|
#
|
2000-01-06 18:17:38 +00:00
|
|
|
mount_null /conf/etc /etc
|
1999-02-09 17:17:18 +00:00
|
|
|
|
|
|
|
# Tell /etc/rc to run the specified script after
|
|
|
|
# it does its mounts but before it does anything
|
|
|
|
# else.
|
|
|
|
#
|
|
|
|
# This script is responsible for setting up the
|
1999-09-13 15:44:20 +00:00
|
|
|
# diskless mount environment. This can be
|
1999-02-09 17:17:18 +00:00
|
|
|
# overriden by /conf/ME/rc.conf.local if, for
|
|
|
|
# example, you do not want to run the standard
|
|
|
|
# system /etc/rc.diskless2
|
|
|
|
|
|
|
|
diskless_mount="/etc/rc.diskless2"
|