Revamp rc.diskless. Split into rc.diskless1 and rc.diskless2. provide
more opportunities for overriding. Clean up /etc/rc ( remove conf_dir, remove startup mount special cases, remove other special cases )
This commit is contained in:
parent
cc766e041e
commit
e4715b9359
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=43803
@ -1,5 +1,5 @@
|
||||
# from: @(#)Makefile 5.11 (Berkeley) 5/21/91
|
||||
# $Id: Makefile,v 1.187 1999/01/13 08:20:53 hm Exp $
|
||||
# $Id: Makefile,v 1.188 1999/01/25 18:24:46 dillon Exp $
|
||||
|
||||
SUBDIR= sendmail
|
||||
|
||||
@ -9,7 +9,7 @@ BIN1= aliases amd.map crontab csh.cshrc csh.login csh.logout dm.conf \
|
||||
newsyslog.conf pam.conf phones pccard.conf.sample \
|
||||
printcap profile protocols \
|
||||
rc rc.atm rc.conf rc.devfs rc.firewall rc.isdn rc.network rc.pccard \
|
||||
rc.diskless rc.serial rc.shutdown \
|
||||
rc.diskless1 rc.diskless2 rc.serial rc.shutdown \
|
||||
etc.${MACHINE_ARCH}/rc.${MACHINE_ARCH} \
|
||||
remote security services shells syslog.conf \
|
||||
etc.${MACHINE_ARCH}/ttys etc.${MACHINE_ARCH}/disktab rpc make.conf \
|
||||
|
51
etc/rc
51
etc/rc
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# $Id: rc,v 1.175 1999/01/31 04:28:51 grog Exp $
|
||||
# $Id: rc,v 1.176 1999/02/09 05:20:46 dillon Exp $
|
||||
# From: @(#)rc 5.27 (Berkeley) 6/5/91
|
||||
|
||||
# System startup script run by init on autoboot
|
||||
@ -23,14 +23,12 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
|
||||
export PATH
|
||||
|
||||
# BOOTP diskless boot. We have to run the rc file early in order to
|
||||
# handle read-only NFS mounts, where the various config files
|
||||
# in /etc often don't apply. rc.diskless typically sets skip_diskconf=YES
|
||||
# on return.
|
||||
# retarget various config files.
|
||||
#
|
||||
if [ -f /etc/rc.diskless ]; then
|
||||
if [ -f /etc/rc.diskless1 ]; then
|
||||
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
|
||||
if [ ${dlv:=0} != 0 ]; then
|
||||
. /etc/rc.diskless
|
||||
. /etc/rc.diskless1
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -41,19 +39,17 @@ if [ -f /etc/rc.conf ]; then
|
||||
fi
|
||||
|
||||
# Configure ccd devices.
|
||||
if [ "X$skip_diskconf" != "XYES" -a -f /etc/ccd.conf ]; then
|
||||
if [ -f /etc/ccd.conf ]; then
|
||||
ccdconfig -C
|
||||
fi
|
||||
|
||||
if [ "X$skip_diskconf" != "XYES" -a -n "$vinum_drives" ]; then
|
||||
if [ -n "$vinum_drives" ]; then
|
||||
vinum read $vinum_drives
|
||||
fi
|
||||
|
||||
if [ "X$skip_diskconf" != "XYES" ]; then
|
||||
swapon -a
|
||||
fi
|
||||
swapon -a
|
||||
|
||||
if [ "X$skip_diskconf" != "XYES" -a $1x = autobootx ]; then
|
||||
if [ $1x = autobootx ]; then
|
||||
echo Automatic reboot in progress...
|
||||
fsck -p
|
||||
case $? in
|
||||
@ -94,31 +90,36 @@ trap "echo 'Reboot interrupted'; exit 1" 3
|
||||
# diskless boot it does not have to be.
|
||||
#
|
||||
|
||||
if [ "X$skip_diskconf" != "XYES" ]; then
|
||||
if [ "X$root_rw_mount" != "XNO" ]; then
|
||||
mount -u -o rw /
|
||||
fi
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
echo "Filesystem mount failed, startup aborted"
|
||||
exit 1
|
||||
fi
|
||||
if [ $? != 0 ]; then
|
||||
echo "Filesystem mount failed, startup aborted"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
umount -a >/dev/null 2>&1
|
||||
umount -a >/dev/null 2>&1
|
||||
|
||||
if [ "X$early_nfs_mounts" != "XYES" ]; then
|
||||
mount -a -t nonfs
|
||||
if [ $? != 0 ]; then
|
||||
echo "Filesystem mount failed, startup aborted"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
mount -a
|
||||
fi
|
||||
if [ $? != 0 ]; then
|
||||
echo "Filesystem mount failed, startup aborted"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run custom disk mounting function here
|
||||
#
|
||||
|
||||
if [ "X$diskless_mount_func" != "X" ]; then
|
||||
$diskless_mount_func
|
||||
if [ "X$diskless_mount" != "X" ]; then
|
||||
if [ -f $diskless_mount ]; then
|
||||
sh $diskless_mount
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# If old file exists, whine until they fix it.
|
||||
if [ -f /etc/sysconfig ]; then
|
||||
echo "Warning: /etc/sysconfig has been replaced by /etc/rc.conf."
|
||||
|
39
etc/rc.d/diskless
Normal file
39
etc/rc.d/diskless
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
# PROVIDE: diskless
|
||||
# REQUIRE: initdiskless mountcritlocal
|
||||
if [ -n "$4" ]; then
|
||||
bpi="-i $4"
|
||||
|
||||
if [ -f /etc/rc.conf ]; then
|
||||
. /etc/rc.conf
|
||||
}
|
||||
|
||||
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
|
||||
chmod 755 /var/run
|
||||
chmod 755 /var/db
|
||||
chmod 755 /var/spool
|
||||
chmod 1777 /var/tmp
|
||||
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
|
||||
|
||||
( 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 )
|
||||
|
||||
# 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
|
||||
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
|
||||
fi
|
100
etc/rc.d/initdiskless
Normal file
100
etc/rc.d/initdiskless
Normal file
@ -0,0 +1,100 @@
|
||||
#
|
||||
# /etc/rc.diskless - 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
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# 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.
|
||||
|
||||
chkerr() {
|
||||
if [ $1 != 0 ]; then
|
||||
echo "$2 failed: dropping into /bin/sh"
|
||||
/bin/sh
|
||||
# RESUME
|
||||
fi
|
||||
}
|
||||
|
||||
# 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"
|
||||
|
||||
# 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.
|
||||
#
|
||||
# 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"
|
||||
|
||||
mkdir /conf/ME
|
||||
cp -Rp /conf/$bootp_ipa/* /conf/ME
|
||||
|
||||
# retarget the kernel
|
||||
#
|
||||
|
||||
sysctl -w kern.bootfile=/conf/ME/kernel
|
||||
|
||||
# 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
|
||||
# diskless mount environment. This can be
|
||||
# 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"
|
||||
|
39
etc/rc.d/resolv
Normal file
39
etc/rc.d/resolv
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
# PROVIDE: diskless
|
||||
# REQUIRE: initdiskless mountcritlocal
|
||||
if [ -n "$4" ]; then
|
||||
bpi="-i $4"
|
||||
|
||||
if [ -f /etc/rc.conf ]; then
|
||||
. /etc/rc.conf
|
||||
}
|
||||
|
||||
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
|
||||
chmod 755 /var/run
|
||||
chmod 755 /var/db
|
||||
chmod 755 /var/spool
|
||||
chmod 1777 /var/tmp
|
||||
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
|
||||
|
||||
( 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 )
|
||||
|
||||
# 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
|
||||
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
|
||||
fi
|
39
etc/rc.d/tmp
Normal file
39
etc/rc.d/tmp
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
# PROVIDE: diskless
|
||||
# REQUIRE: initdiskless mountcritlocal
|
||||
if [ -n "$4" ]; then
|
||||
bpi="-i $4"
|
||||
|
||||
if [ -f /etc/rc.conf ]; then
|
||||
. /etc/rc.conf
|
||||
}
|
||||
|
||||
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
|
||||
chmod 755 /var/run
|
||||
chmod 755 /var/db
|
||||
chmod 755 /var/spool
|
||||
chmod 1777 /var/tmp
|
||||
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
|
||||
|
||||
( 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 )
|
||||
|
||||
# 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
|
||||
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
|
||||
fi
|
39
etc/rc.d/var
Normal file
39
etc/rc.d/var
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
# PROVIDE: diskless
|
||||
# REQUIRE: initdiskless mountcritlocal
|
||||
if [ -n "$4" ]; then
|
||||
bpi="-i $4"
|
||||
|
||||
if [ -f /etc/rc.conf ]; then
|
||||
. /etc/rc.conf
|
||||
}
|
||||
|
||||
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
|
||||
chmod 755 /var/run
|
||||
chmod 755 /var/db
|
||||
chmod 755 /var/spool
|
||||
chmod 1777 /var/tmp
|
||||
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
|
||||
|
||||
( 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 )
|
||||
|
||||
# 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
|
||||
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
|
||||
fi
|
142
etc/rc.diskless
142
etc/rc.diskless
@ -1,142 +0,0 @@
|
||||
#
|
||||
# /etc/rc.diskless - 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
|
||||
# - mount /usr via nfs
|
||||
# - figure out our IP by querying the interface
|
||||
# - setup the configuration script directory
|
||||
# - setup the configuration function
|
||||
#
|
||||
# SEE SAMPLE FILES IN /usr/share/examples/diskless. If you have nothing
|
||||
# better to do, try:
|
||||
#
|
||||
# ln -s /usr/share/examples/diskless /conf
|
||||
#
|
||||
# but at least read the README.
|
||||
|
||||
# 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.
|
||||
|
||||
chkerr() {
|
||||
if [ $1 != 0 ]; then
|
||||
echo "$2 failed: dropping into /bin/sh"
|
||||
/bin/sh
|
||||
# RESUME
|
||||
fi
|
||||
}
|
||||
|
||||
# DEBUGGING
|
||||
#
|
||||
set -v
|
||||
|
||||
# Figure out where the root mount is coming from, synthesize a mount
|
||||
# for /usr and mount it. Also mount /var
|
||||
#
|
||||
# e.g. nfs_root might wind up as "A.B.C.D:/"
|
||||
#
|
||||
set `/bin/df /`
|
||||
nfs_root=$8
|
||||
mount_nfs -o ro ${nfs_root}/usr /usr
|
||||
|
||||
chkerr $? "mount of /usr"
|
||||
|
||||
# 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"
|
||||
|
||||
# retarget the configuration directory, where rc.conf.local and rc.local
|
||||
# are found. We set the directory to /conf/$bootp_ipa. 'conf_dir' will
|
||||
# be used by rc.conf and later in /etc/rc.
|
||||
#
|
||||
# retarget the kernel ( put a softlink in your conf directory to point to
|
||||
# the correct kernel ).
|
||||
|
||||
conf_dir=/conf/$bootp_ipa
|
||||
sysctl -w kern.bootfile=$conf_dir/kernel
|
||||
|
||||
if [ ! -f $conf_dir/rc.conf.local ]; then
|
||||
chkerr 1 "access to $conf_dir"
|
||||
fi
|
||||
|
||||
# Tell /etc/rc to skip normal disk configuration and replace
|
||||
# it with our own.
|
||||
#
|
||||
skip_diskconf=YES
|
||||
diskless_mount_func=diskless_mount_system
|
||||
|
||||
# Set defaults for MFS filesystem sizes. These can get overriden by
|
||||
# rc.conf when diskless_mount_system is called back. NOTE! These
|
||||
# defaults are generous, but may be too large for your memory/swap
|
||||
# configuration. Large is ok as long as you have sufficient NFS swap.
|
||||
#
|
||||
var_run_sectors=2048
|
||||
var_db_sectors=16384
|
||||
var_tmp_sectors=65536
|
||||
var_spool_sectors=65536
|
||||
|
||||
# Default mounting pass procedure
|
||||
#
|
||||
# We have to create the filesystems that are expected
|
||||
# to be writeable.
|
||||
|
||||
diskless_mount_system() {
|
||||
sysctl -w net.inet.ip.portrange.first=4000
|
||||
|
||||
# This is kinda a hack at the moment. Typically, we do not want to
|
||||
# export /var from the server root due to security considerations,
|
||||
# even read-only. XXX fixme. See the tail end of the
|
||||
# /usr/share/examples/diskless/README.TEMPLATING file for the
|
||||
# reasoning and other security considerations.
|
||||
#
|
||||
if [ "X$nfs_var_mount" != "XNO" ]; then
|
||||
mount_nfs -o ro ${nfs_root}/var /var
|
||||
fi
|
||||
mount_mfs -s $var_run_sectors -T qp120at dummy /var/run
|
||||
mount_mfs -s $var_db_sectors -T qp120at dummy /var/db
|
||||
mount_mfs -s $var_tmp_sectors -T qp120at dummy /var/tmp
|
||||
mount_mfs -s $var_spool_sectors -T qp120at dummy /var/spool
|
||||
chmod 755 /var/run
|
||||
chmod 755 /var/db
|
||||
chmod 755 /var/spool
|
||||
chmod 1777 /var/tmp
|
||||
|
||||
# /tmp should be a softlink to /var/tmp on most systems. If it isn't,
|
||||
# use nullfs
|
||||
#
|
||||
if [ ! -h /tmp -a ! -h /var/tmp ]; then
|
||||
mount_null /var/tmp /tmp
|
||||
fi
|
||||
|
||||
# Create a skeleton spool
|
||||
#
|
||||
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
|
||||
|
||||
# /proc may be necessary
|
||||
#
|
||||
mount_procfs proc /proc
|
||||
|
||||
# We need a R+W /dev ! Use cpio to copy /dev from the
|
||||
# server to an MFS mount.
|
||||
|
||||
mkdir /tmp/root
|
||||
mount ${nfs_root} /tmp/root
|
||||
mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
|
||||
( cd /tmp/root ; find -x dev | cpio -o -H newc ) | \
|
||||
( cd / ; cpio -i -H newc -d )
|
||||
umount /tmp/root
|
||||
}
|
||||
|
100
etc/rc.diskless1
Normal file
100
etc/rc.diskless1
Normal file
@ -0,0 +1,100 @@
|
||||
#
|
||||
# /etc/rc.diskless - 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
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# 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.
|
||||
|
||||
chkerr() {
|
||||
if [ $1 != 0 ]; then
|
||||
echo "$2 failed: dropping into /bin/sh"
|
||||
/bin/sh
|
||||
# RESUME
|
||||
fi
|
||||
}
|
||||
|
||||
# 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"
|
||||
|
||||
# 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.
|
||||
#
|
||||
# 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"
|
||||
|
||||
mkdir /conf/ME
|
||||
cp -Rp /conf/$bootp_ipa/* /conf/ME
|
||||
|
||||
# retarget the kernel
|
||||
#
|
||||
|
||||
sysctl -w kern.bootfile=/conf/ME/kernel
|
||||
|
||||
# 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
|
||||
# diskless mount environment. This can be
|
||||
# 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"
|
||||
|
34
etc/rc.diskless2
Normal file
34
etc/rc.diskless2
Normal file
@ -0,0 +1,34 @@
|
||||
# rc.diskless2
|
||||
#
|
||||
|
||||
# If there is a global system configuration file, suck it in.
|
||||
#
|
||||
|
||||
if [ -f /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
|
||||
chmod 755 /var/run
|
||||
chmod 755 /var/db
|
||||
chmod 755 /var/spool
|
||||
chmod 1777 /var/tmp
|
||||
|
||||
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
|
||||
|
||||
( 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 )
|
||||
|
100
etc/rc.initdiskless
Normal file
100
etc/rc.initdiskless
Normal file
@ -0,0 +1,100 @@
|
||||
#
|
||||
# /etc/rc.diskless - 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
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# 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.
|
||||
|
||||
chkerr() {
|
||||
if [ $1 != 0 ]; then
|
||||
echo "$2 failed: dropping into /bin/sh"
|
||||
/bin/sh
|
||||
# RESUME
|
||||
fi
|
||||
}
|
||||
|
||||
# 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"
|
||||
|
||||
# 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.
|
||||
#
|
||||
# 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"
|
||||
|
||||
mkdir /conf/ME
|
||||
cp -Rp /conf/$bootp_ipa/* /conf/ME
|
||||
|
||||
# retarget the kernel
|
||||
#
|
||||
|
||||
sysctl -w kern.bootfile=/conf/ME/kernel
|
||||
|
||||
# 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
|
||||
# diskless mount environment. This can be
|
||||
# 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"
|
||||
|
Loading…
Reference in New Issue
Block a user