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>
This commit is contained in:
parent
dd4450d659
commit
4f9b3f5f33
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=55520
@ -11,26 +11,28 @@
|
||||
/sbin/mount /dev/md$3c $2
|
||||
}
|
||||
|
||||
mount_mfs -s ${var_run_sectors:=2048} -T qp120at dummy /var/run
|
||||
mount_mfs -s ${var_db_sectors:=16384} -T qp120at dummy /var/db
|
||||
mount_mfs -s ${var_tmp_sectors:=65536} -T qp120at dummy /var/tmp
|
||||
mount_mfs -s ${var_spool_sectors:=65536} -T qp120at dummy /var/spool
|
||||
mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
|
||||
var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
|
||||
spool/output/lpd"
|
||||
for i in ${var_dirs}
|
||||
do
|
||||
mkdir /var/${i}
|
||||
done
|
||||
chmod 755 /var/run
|
||||
chmod 755 /var/db
|
||||
chmod 755 /var/spool
|
||||
chmod 1777 /var/tmp
|
||||
chown -R root.daemon /var/spool/output
|
||||
chgrp daemon /var/spool/lpd
|
||||
# Since we are starting with a very fresh /etc on an MFS:
|
||||
if [ -d /conf/default/etc ]; then
|
||||
newaliases
|
||||
fi
|
||||
if [ ! -h /tmp -a ! -h /var/tmp ]; then
|
||||
mount_null /var/tmp /tmp
|
||||
fi
|
||||
#
|
||||
mkdir /var/spool/mqueue
|
||||
mkdir /var/spool/lpd
|
||||
mkdir /var/spool/output
|
||||
mkdir /var/spool/output/lpd
|
||||
chown -R root.daemon /var/spool/output
|
||||
chgrp daemon /var/spool/lpd
|
||||
|
||||
# extract a list of device entries, then copy them to a writable partition
|
||||
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
|
||||
mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
|
||||
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
|
||||
|
@ -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
|
||||
|
@ -11,26 +11,28 @@
|
||||
/sbin/mount /dev/md$3c $2
|
||||
}
|
||||
|
||||
mount_mfs -s ${var_run_sectors:=2048} -T qp120at dummy /var/run
|
||||
mount_mfs -s ${var_db_sectors:=16384} -T qp120at dummy /var/db
|
||||
mount_mfs -s ${var_tmp_sectors:=65536} -T qp120at dummy /var/tmp
|
||||
mount_mfs -s ${var_spool_sectors:=65536} -T qp120at dummy /var/spool
|
||||
mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
|
||||
var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
|
||||
spool/output/lpd"
|
||||
for i in ${var_dirs}
|
||||
do
|
||||
mkdir /var/${i}
|
||||
done
|
||||
chmod 755 /var/run
|
||||
chmod 755 /var/db
|
||||
chmod 755 /var/spool
|
||||
chmod 1777 /var/tmp
|
||||
chown -R root.daemon /var/spool/output
|
||||
chgrp daemon /var/spool/lpd
|
||||
# Since we are starting with a very fresh /etc on an MFS:
|
||||
if [ -d /conf/default/etc ]; then
|
||||
newaliases
|
||||
fi
|
||||
if [ ! -h /tmp -a ! -h /var/tmp ]; then
|
||||
mount_null /var/tmp /tmp
|
||||
fi
|
||||
#
|
||||
mkdir /var/spool/mqueue
|
||||
mkdir /var/spool/lpd
|
||||
mkdir /var/spool/output
|
||||
mkdir /var/spool/output/lpd
|
||||
chown -R root.daemon /var/spool/output
|
||||
chgrp daemon /var/spool/lpd
|
||||
|
||||
# extract a list of device entries, then copy them to a writable partition
|
||||
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
|
||||
mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
|
||||
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
|
||||
|
24
etc/rc.d/tmp
24
etc/rc.d/tmp
@ -11,26 +11,28 @@
|
||||
/sbin/mount /dev/md$3c $2
|
||||
}
|
||||
|
||||
mount_mfs -s ${var_run_sectors:=2048} -T qp120at dummy /var/run
|
||||
mount_mfs -s ${var_db_sectors:=16384} -T qp120at dummy /var/db
|
||||
mount_mfs -s ${var_tmp_sectors:=65536} -T qp120at dummy /var/tmp
|
||||
mount_mfs -s ${var_spool_sectors:=65536} -T qp120at dummy /var/spool
|
||||
mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
|
||||
var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
|
||||
spool/output/lpd"
|
||||
for i in ${var_dirs}
|
||||
do
|
||||
mkdir /var/${i}
|
||||
done
|
||||
chmod 755 /var/run
|
||||
chmod 755 /var/db
|
||||
chmod 755 /var/spool
|
||||
chmod 1777 /var/tmp
|
||||
chown -R root.daemon /var/spool/output
|
||||
chgrp daemon /var/spool/lpd
|
||||
# Since we are starting with a very fresh /etc on an MFS:
|
||||
if [ -d /conf/default/etc ]; then
|
||||
newaliases
|
||||
fi
|
||||
if [ ! -h /tmp -a ! -h /var/tmp ]; then
|
||||
mount_null /var/tmp /tmp
|
||||
fi
|
||||
#
|
||||
mkdir /var/spool/mqueue
|
||||
mkdir /var/spool/lpd
|
||||
mkdir /var/spool/output
|
||||
mkdir /var/spool/output/lpd
|
||||
chown -R root.daemon /var/spool/output
|
||||
chgrp daemon /var/spool/lpd
|
||||
|
||||
# extract a list of device entries, then copy them to a writable partition
|
||||
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
|
||||
mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
|
||||
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
|
||||
|
24
etc/rc.d/var
24
etc/rc.d/var
@ -11,26 +11,28 @@
|
||||
/sbin/mount /dev/md$3c $2
|
||||
}
|
||||
|
||||
mount_mfs -s ${var_run_sectors:=2048} -T qp120at dummy /var/run
|
||||
mount_mfs -s ${var_db_sectors:=16384} -T qp120at dummy /var/db
|
||||
mount_mfs -s ${var_tmp_sectors:=65536} -T qp120at dummy /var/tmp
|
||||
mount_mfs -s ${var_spool_sectors:=65536} -T qp120at dummy /var/spool
|
||||
mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
|
||||
var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
|
||||
spool/output/lpd"
|
||||
for i in ${var_dirs}
|
||||
do
|
||||
mkdir /var/${i}
|
||||
done
|
||||
chmod 755 /var/run
|
||||
chmod 755 /var/db
|
||||
chmod 755 /var/spool
|
||||
chmod 1777 /var/tmp
|
||||
chown -R root.daemon /var/spool/output
|
||||
chgrp daemon /var/spool/lpd
|
||||
# Since we are starting with a very fresh /etc on an MFS:
|
||||
if [ -d /conf/default/etc ]; then
|
||||
newaliases
|
||||
fi
|
||||
if [ ! -h /tmp -a ! -h /var/tmp ]; then
|
||||
mount_null /var/tmp /tmp
|
||||
fi
|
||||
#
|
||||
mkdir /var/spool/mqueue
|
||||
mkdir /var/spool/lpd
|
||||
mkdir /var/spool/output
|
||||
mkdir /var/spool/output/lpd
|
||||
chown -R root.daemon /var/spool/output
|
||||
chgrp daemon /var/spool/lpd
|
||||
|
||||
# extract a list of device entries, then copy them to a writable partition
|
||||
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
|
||||
mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
|
||||
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
|
||||
|
107
etc/rc.diskless1
107
etc/rc.diskless1
@ -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
|
||||
|
@ -11,26 +11,28 @@ elif [ -r /etc/rc.conf ]; then
|
||||
. /etc/rc.conf
|
||||
fi
|
||||
|
||||
mount_mfs -s ${var_run_sectors:=2048} -T qp120at dummy /var/run
|
||||
mount_mfs -s ${var_db_sectors:=16384} -T qp120at dummy /var/db
|
||||
mount_mfs -s ${var_tmp_sectors:=65536} -T qp120at dummy /var/tmp
|
||||
mount_mfs -s ${var_spool_sectors:=65536} -T qp120at dummy /var/spool
|
||||
mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
|
||||
var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
|
||||
spool/output/lpd"
|
||||
for i in ${var_dirs}
|
||||
do
|
||||
mkdir /var/${i}
|
||||
done
|
||||
chmod 755 /var/run
|
||||
chmod 755 /var/db
|
||||
chmod 755 /var/spool
|
||||
chmod 1777 /var/tmp
|
||||
chown -R root.daemon /var/spool/output
|
||||
chgrp daemon /var/spool/lpd
|
||||
#
|
||||
# XXX make sure to create one dir for each printer as requested by lpd
|
||||
#
|
||||
|
||||
if [ ! -h /tmp -a ! -h /var/tmp ]; then
|
||||
mount_null /var/tmp /tmp
|
||||
fi
|
||||
|
||||
mkdir /var/spool/mqueue
|
||||
mkdir /var/spool/lpd
|
||||
mkdir /var/spool/output
|
||||
mkdir /var/spool/output/lpd
|
||||
chown -R root.daemon /var/spool/output
|
||||
chgrp daemon /var/spool/lpd
|
||||
|
||||
# extract a list of device entries, then copy them to a writable partition
|
||||
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
|
||||
mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
|
||||
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user