2 # /etc/rc.diskless - general BOOTP startup
4 # BOOTP has mounted / for us. Assume a read-only mount. We must then
5 # - figure out where the NFS mount is coming from
6 # - figure out our IP by querying the interface
7 # - retarget /conf/ME softlink to proper configuration script directory
9 # It is expected that /etc/fstab and /etc/rc.conf.local will be
10 # set by the system operator on the server to be softlinks to
11 # /conf/ME/fstab and /conf/ME/rc.conf.local. The system operator may
12 # choose to retarget other files as well. The server itself boots
13 # properly with its default /conf/ME softlink pointing to
14 # /conf/server.host.name.
16 # During a diskless boot, we retarget the /conf/ME softlink to point
17 # to /conf/DISKLESS.CLIENT.IP.ADDRESS. Thus, various system config
18 # files that are softlinks through /conf/ME also get retargeted.
20 # SEE SAMPLE FILES IN /usr/share/examples/diskless.
24 # Routine to check for error
26 # checks error code and drops into shell on failure.
27 # if shell exits, terminates script as well as /etc/rc.
31 echo "$2 failed: dropping into /bin/sh"
41 # Figure out where the root mount is coming from, synthesize a mount
42 # for /usr and mount it.
44 # e.g. nfs_root might wind up as "A.B.C.D:/"
46 # NOTE! the /usr mount is only temporary so we can access commands necessary
47 # to retarget /conf/ME. The actual /usr mount should be part of the
48 # retargeted /etc/fstab. See instructions in /usr/share/examples/diskless.
52 mount_nfs -o ro ${nfs_root}/usr /usr
54 chkerr $? "mount of /usr"
56 # Figure out our interface and IP.
59 bootp_ifc=`route -n get default | fgrep interface | awk '{ print $2; }'`
60 bootp_ipa=`ifconfig $bootp_ifc | fgrep inet | head -1 | awk '{ print $2; }'`
62 echo "Interface $bootp_ifc IP-Address $bootp_ipa"
68 # MFS's background process takes a bit to startup. Various config files
69 # on server should be softlinks through /conf/ME. The server's own /conf/ME
70 # points to the server's version of the files.
72 # We retarget /conf/ME using a -o union mount. This allows
73 # us to 'mkdir' over whatever was there previously.
75 # WARNING! null mounts cannot handle mmap, and since many programs
76 # use mmap (such as 'cp'), we have to copy.
78 mount_mfs -s 256 -T qp120at -o union dummy /conf
79 chkerr $? "MFS mount on /conf"
82 cp -Rp /conf/$bootp_ipa/* /conf/ME
87 sysctl -w kern.bootfile=/conf/ME/kernel
89 # Tell /etc/rc to run the specified script after
90 # it does its mounts but before it does anything
93 # This script is responsible for setting up the
94 # diskless mount environment. This can be
95 # overriden by /conf/ME/rc.conf.local if, for
96 # example, you do not want to run the standard
97 # system /etc/rc.diskless2
99 diskless_mount="/etc/rc.diskless2"