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