# # /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 # # XXX # 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 # XXX we should extract the host part from nfs_root, but we don't have # any good tool for string parsing yet. The ../ is a dirty hack. We # can add more than one. But this whole section to determine the boot # ifc etc. needs some cleanup 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; }'` bootp_ipbca=`ifconfig $bootp_ifc | fgrep inet | head -1 | awk '{ print $6; }'` echo "Interface $bootp_ifc IP-Address $bootp_ipa Broadcast $bootp_ipbca" umount /usr # 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 2048 -T qp120at dummy /conf/etc cp -Rp /etc/* /conf/etc chkerr $? "MFS mount on /conf/etc" 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 # # Make the new directory available as /etc # mount_null /conf/etc /etc # 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"