rc.initdiskless revision 55520
1# $FreeBSD: head/etc/rc.initdiskless 55520 2000-01-06 18:17:38Z luigi $ 2# 3# /etc/rc.diskless1 - general BOOTP startup 4# 5# BOOTP has mounted / for us. Assume a read-only mount. We must then 6# - figure out our IP by querying the interface 7# - fill /conf/etc (writable) with files from /etc, and then update 8# per-machine files from /conf/*/ where * is the IP of the host, 9# the IP of the subnet, "default", or nothing. 10# - mount /conf/etc over /etc so we can see the new files. 11# 12# WARNING: i thing you should not change /etc/rc or strange things could 13# happen. 14# 15# The operator is in charge of setting /conf/*/etc/* things as appropriate. 16# Typically rc.conf and fstab need to be changed, but possibly 17# also other files such as inetd.conf etc. 18 19# chkerr: 20# 21# Routine to check for error 22# 23# checks error code and drops into shell on failure. 24# if shell exits, terminates script as well as /etc/rc. 25# 26chkerr() { 27 case $1 in 28 0) 29 ;; 30 *) 31 echo "$2 failed: dropping into /bin/sh" 32 /bin/sh 33 # RESUME 34 ;; 35 esac 36} 37 38# DEBUGGING 39# 40# set -v 41 42# Figure out our interface and IP. 43# 44bootp_ifc="" 45bootp_ipa="" 46bootp_ipbca="" 47iflist=`ifconfig -l` 48for i in ${iflist} ; do 49 set `ifconfig ${i}` 50 while [ $# -ge 1 ] ; do 51 if [ "${bootp_ifc}" = "" -a "$1" = "inet" ] ; then 52 bootp_ifc=${i} ; bootp_ipa=${2} ; shift 53 fi 54 if [ "${bootp_ipbca}" = "" -a "$1" = "broadcast" ] ; then 55 bootp_ipbca=$2; shift 56 fi 57 shift 58 done 59 if [ "${bootp_ifc}" != "" ] ; then 60 break 61 fi 62done 63echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}" 64 65# Files in /etc are copied to /conf/etc which is writable. Then 66# per-machine configs from /conf/ip.address/etc are copied onto this 67# directory. First choice is using the client's IP, then the client's 68# broadcast address, then a default configuration. 69# This way we have some flexibility to handle clusters of machines 70# on separate subnets. 71# 72# WARNING! null mounts cannot handle mmap, and since many programs 73# use mmap (such as 'cp'), we have to copy. 74# 75mount_mfs -s 2048 -T qp120at dummy /conf/etc 76cp -Rp /etc/* /conf/etc 77chkerr $? "MFS mount on /conf/etc" 78 79if [ -d /conf/${bootp_ipa} ] ; then 80 cp -Rp /conf/${bootp_ipa}/etc/* /conf/etc 81elif [ -d /conf/${bootp_ipbca} ] ; then 82 cp -Rp /conf/${bootp_ipbca}/etc/* /conf/etc 83else 84 cp -Rp /conf/default/etc/* /conf/etc 85fi 86 87# Make the new directory available as /etc 88# 89mount_null /conf/etc /etc 90 91# Tell /etc/rc to run the specified script after 92# it does its mounts but before it does anything 93# else. 94# 95# This script is responsible for setting up the 96# diskless mount environment. This can be 97# overriden by /conf/ME/rc.conf.local if, for 98# example, you do not want to run the standard 99# system /etc/rc.diskless2 100 101diskless_mount="/etc/rc.diskless2" 102