rc.initdiskless (95280) | rc.initdiskless (100280) |
---|---|
1#!/bin/sh 2# |
|
1# Copyright (c) 1999 Matt Dillion 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions 6# are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. --- 8 unchanged lines hidden (view full) --- 17# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23# SUCH DAMAGE. 24# | 3# Copyright (c) 1999 Matt Dillion 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. --- 8 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# |
25# $FreeBSD: head/etc/rc.initdiskless 95280 2002-04-22 21:42:18Z obrien $ | 27# $FreeBSD: head/etc/rc.initdiskless 100280 2002-07-18 05:00:17Z gordon $ |
26# 27 | 28# 29 |
30# PROVIDE: initdiskless 31# KEYWORD: FreeBSD 32 33dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 34[ ${dlv:=0} -eq 0 ] && exit 0 35 |
|
28# | 36# |
29# /etc/rc.diskless1 - general BOOTP startup 30# | |
31# BOOTP has mounted / for us. Assume a read-only mount. We must then 32# - figure out our IP by querying the interface 33# - mount /etc as an MFS 34# - populate /etc from /conf/default version 35# - override files in /etc with files from /conf/*/etc where 36# '*' is default, netmask of client, ip-address of client 37# 38# The operator is in charge of setting /conf/*/etc/* things as appropriate. 39# Typically rc.conf and fstab need to be changed, but possibly also other 40# files such as inetd.conf etc. 41 42# chkerr: 43# 44# Routine to check for error 45# 46# checks error code and drops into shell on failure. 47# if shell exits, terminates script as well as /etc/rc. 48# | 37# BOOTP has mounted / for us. Assume a read-only mount. We must then 38# - figure out our IP by querying the interface 39# - mount /etc as an MFS 40# - populate /etc from /conf/default version 41# - override files in /etc with files from /conf/*/etc where 42# '*' is default, netmask of client, ip-address of client 43# 44# The operator is in charge of setting /conf/*/etc/* things as appropriate. 45# Typically rc.conf and fstab need to be changed, but possibly also other 46# files such as inetd.conf etc. 47 48# chkerr: 49# 50# Routine to check for error 51# 52# checks error code and drops into shell on failure. 53# if shell exits, terminates script as well as /etc/rc. 54# |
49chkerr() { | 55chkerr() 56{ |
50 case $1 in 51 0) 52 ;; 53 *) 54 echo "$2 failed: dropping into /bin/sh" 55 /bin/sh 56 # RESUME 57 ;; 58 esac 59} 60 | 57 case $1 in 58 0) 59 ;; 60 *) 61 echo "$2 failed: dropping into /bin/sh" 62 /bin/sh 63 # RESUME 64 ;; 65 esac 66} 67 |
61mount_md() { | 68mount_md() 69{ |
62 /sbin/mdconfig -a -t malloc -s $1 -u $3 63 /sbin/disklabel -r -w md$3 auto 64 /sbin/newfs /dev/md$3c 65 /sbin/mount /dev/md$3c $2 66} 67 68# DEBUGGING 69# --- 18 unchanged lines hidden (view full) --- 88 done 89 if [ "${bootp_ifc}" != "" ] ; then 90 break 91 fi 92done 93echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}" 94 95if [ -z "`hostname -s`" ]; then | 70 /sbin/mdconfig -a -t malloc -s $1 -u $3 71 /sbin/disklabel -r -w md$3 auto 72 /sbin/newfs /dev/md$3c 73 /sbin/mount /dev/md$3c $2 74} 75 76# DEBUGGING 77# --- 18 unchanged lines hidden (view full) --- 96 done 97 if [ "${bootp_ifc}" != "" ] ; then 98 break 99 fi 100done 101echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}" 102 103if [ -z "`hostname -s`" ]; then |
96 hostname=`kenv dhcp.host-name` 97 hostname $hostname | 104 hostname=`kenv dhcp.host-name` 105 hostname $hostname |
98 echo "Hostname is $hostname" 99fi 100 101if [ -d /conf/default/etc ]; then 102 mount_md 4096 /etc 0 103 chkerr $? "MFS mount on /etc" 104 /bin/chmod 755 /etc 105 --- 15 unchanged lines hidden (view full) --- 121 fi 122done 123 124# 125# if the info is available via dhcp/kenv 126# build the resolv.conf 127# 128if [ ! -e /etc/resolv.conf ]; then | 106 echo "Hostname is $hostname" 107fi 108 109if [ -d /conf/default/etc ]; then 110 mount_md 4096 /etc 0 111 chkerr $? "MFS mount on /etc" 112 /bin/chmod 755 /etc 113 --- 15 unchanged lines hidden (view full) --- 129 fi 130done 131 132# 133# if the info is available via dhcp/kenv 134# build the resolv.conf 135# 136if [ ! -e /etc/resolv.conf ]; then |
129 echo domain `kenv dhcp.domain-name` > /etc/resolv.conf | 137 echo domain `kenv dhcp.domain-name` > /etc/resolv.conf |
130 | 138 |
131 set `kenv dhcp.domain-name-servers` 132 for ns in `IFS=','; echo $*`; do 133 echo nameserver $ns >> /etc/resolv.conf; 134 done | 139 set `kenv dhcp.domain-name-servers` 140 for ns in `IFS=','; echo $*`; do 141 echo nameserver $ns >> /etc/resolv.conf; 142 done |
135fi | 143fi |
136 137# Tell /etc/rc to run the specified script after it does its mounts but 138# before it does anything else. 139# 140# This script is responsible for setting up the diskless mount environment. 141# This can be overriden by /conf/ME/rc.conf.local if, for example, you do not 142# want to run the standard system /etc/rc.diskless2 143 144diskless_mount="/etc/rc.diskless2" | |