rc.initdiskless (50357) | rc.initdiskless (51231) |
---|---|
1# | 1# |
2# $FreeBSD: head/etc/rc.initdiskless 51231 1999-09-13 15:44:20Z sheldonh $ 3# |
|
2# /etc/rc.diskless - general BOOTP startup 3# 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 8# 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 | 4# /etc/rc.diskless - general BOOTP startup 5# 6# BOOTP has mounted / for us. Assume a read-only mount. We must then 7# - figure out where the NFS mount is coming from 8# - figure out our IP by querying the interface 9# - retarget /conf/ME softlink to proper configuration script directory 10# 11# It is expected that /etc/fstab and /etc/rc.conf.local will be 12# set by the system operator on the server to be softlinks to 13# /conf/ME/fstab and /conf/ME/rc.conf.local. The system operator may 14# 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. | 15# properly with its default /conf/ME softlink pointing to 16# /conf/server.host.name. |
15# 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. 19# | 17# 18# During a diskless boot, we retarget the /conf/ME softlink to point 19# to /conf/DISKLESS.CLIENT.IP.ADDRESS. Thus, various system config 20# files that are softlinks through /conf/ME also get retargeted. 21# |
20# SEE SAMPLE FILES IN /usr/share/examples/diskless. | 22# SEE SAMPLE FILES IN /usr/share/examples/diskless. |
21 22# chkerr: 23# 24# Routine to check for error 25# 26# checks error code and drops into shell on failure. 27# if shell exits, terminates script as well as /etc/rc. | 23 24# chkerr: 25# 26# Routine to check for error 27# 28# checks error code and drops into shell on failure. 29# if shell exits, terminates script as well as /etc/rc. |
28 | 30# |
29chkerr() { | 31chkerr() { |
30 if [ $1 != 0 ]; then | 32 case $1 in 33 0) 34 ;; 35 *) |
31 echo "$2 failed: dropping into /bin/sh" 32 /bin/sh 33 # RESUME | 36 echo "$2 failed: dropping into /bin/sh" 37 /bin/sh 38 # RESUME |
34 fi | 39 ;; 40 esac |
35} 36 37# DEBUGGING 38# 39set -v 40 | 41} 42 43# DEBUGGING 44# 45set -v 46 |
41# Figure out where the root mount is coming from, synthesize a mount 42# for /usr and mount it. | 47# Figure out where the root mount is coming from, synthesize a mount 48# for /usr and mount it. |
43# | 49# |
44# e.g. nfs_root might wind up as "A.B.C.D:/" | 50# e.g. nfs_root might wind up as "A.B.C.D:/" |
45# | 51# |
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# NOTE! the /usr mount is only temporary so we can access commands necessary 53# to retarget /conf/ME. The actual /usr mount should be part of the 54# retargeted /etc/fstab. See instructions in /usr/share/examples/diskless. |
49# 50set `/bin/df /` 51nfs_root=$8 52mount_nfs -o ro ${nfs_root}/usr /usr 53 54chkerr $? "mount of /usr" 55 | 55# 56set `/bin/df /` 57nfs_root=$8 58mount_nfs -o ro ${nfs_root}/usr /usr 59 60chkerr $? "mount of /usr" 61 |
56# Figure out our interface and IP. | 62# Figure out our interface and IP. |
57# 58 59bootp_ifc=`route -n get default | fgrep interface | awk '{ print $2; }'` 60bootp_ipa=`ifconfig ${bootp_ifc} | fgrep inet | head -1 | awk '{ print $2; }'` 61 62echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa}" 63 64umount /usr --- 4 unchanged lines hidden (view full) --- 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. 71# 72# We retarget /conf/ME using a -o union mount. This allows 73# us to 'mkdir' over whatever was there previously. 74# 75# WARNING! null mounts cannot handle mmap, and since many programs 76# use mmap (such as 'cp'), we have to copy. | 63# 64 65bootp_ifc=`route -n get default | fgrep interface | awk '{ print $2; }'` 66bootp_ipa=`ifconfig ${bootp_ifc} | fgrep inet | head -1 | awk '{ print $2; }'` 67 68echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa}" 69 70umount /usr --- 4 unchanged lines hidden (view full) --- 75# on server should be softlinks through /conf/ME. The server's own /conf/ME 76# points to the server's version of the files. 77# 78# We retarget /conf/ME using a -o union mount. This allows 79# us to 'mkdir' over whatever was there previously. 80# 81# WARNING! null mounts cannot handle mmap, and since many programs 82# use mmap (such as 'cp'), we have to copy. |
77 | 83# |
78mount_mfs -s 256 -T qp120at -o union dummy /conf 79chkerr $? "MFS mount on /conf" 80 81mkdir /conf/ME 82cp -Rp /conf/$bootp_ipa/* /conf/ME 83 84# retarget the kernel 85# 86 87sysctl -w kern.bootfile=/conf/ME/kernel 88 89# Tell /etc/rc to run the specified script after 90# it does its mounts but before it does anything 91# else. 92# 93# This script is responsible for setting up the | 84mount_mfs -s 256 -T qp120at -o union dummy /conf 85chkerr $? "MFS mount on /conf" 86 87mkdir /conf/ME 88cp -Rp /conf/$bootp_ipa/* /conf/ME 89 90# retarget the kernel 91# 92 93sysctl -w kern.bootfile=/conf/ME/kernel 94 95# Tell /etc/rc to run the specified script after 96# it does its mounts but before it does anything 97# else. 98# 99# This script is responsible for setting up the |
94# diskless mount environment. This can be | 100# 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 98 99diskless_mount="/etc/rc.diskless2" | 101# overriden by /conf/ME/rc.conf.local if, for 102# example, you do not want to run the standard 103# system /etc/rc.diskless2 104 105diskless_mount="/etc/rc.diskless2" |