]>
git.saurik.com Git - apple/launchd.git/blob - launchd/src/rc.netboot
6eab9ab70a305037b2893c8403664e50f9431bc5
3 # Copyright 2002 Apple Computer, Inc.
5 # This script configures NetBoot
11 # Define: NETBOOT_SHADOW
13 # To change the behavior of the system when choosing a netboot shadow
16 # -NETWORK- Try to use the network for the shadow file, if
17 # that fails, use the local drive
18 # -NETWORK_ONLY- Only use the network, fail if not available
19 # -LOCAL- Use the local drive for the shadow file, if that
20 # fails, use the network
21 # -LOCAL_ONLY- Only use the local drive for the shadow, fail if
24 NETBOOT_MOUNT
=/var
/netboot
25 NETBOOT_SHADOW
=${NETBOOT_SHADOW:-NETWORK-}
37 if [ "${netboot_dir}" = "" ] ; then
38 Failed
"netboot_dir is empty"
40 if [ "${netboot_shadow}" = "" ] ; then
41 Failed
"netboot_shadow is empty"
43 netboot_shadow
="${netboot_dir}/${netboot_shadow}"
44 if ! mkdir -p "${netboot_dir}" ; then
45 Failed
"create ${netboot_dir} failed"
47 chmod 700 "${netboot_dir}"
49 root_device
=$(mount | sed -n 's:/dev/\(.*\) on
/ .
*:\
1:p
')
50 case "${root_device}" in
52 if ! touch "${netboot_shadow}" ; then
53 Failed "create ${netboot_shadow} failed"
55 chmod 600 "${netboot_shadow}"
56 if ! /usr/libexec/vndevice shadow "/dev/r${root_device}" "${netboot_shadow}" ; then
57 Failed "vndevice shadow failed"
61 Failed "root device unknown"
64 if ! touch "${netboot_shadow}" ; then
65 Failed "failed to create shadow ${netboot_shadow}"
67 chmod 600 "${netboot_shadow}"
68 if ! /usr/bin/nbdst -recycle "${root_device}" "${netboot_shadow}" ; then
77 volinfo=`autodiskmount -F 2>/dev/null`
79 echo "autodiskmount -F found no local drives"
86 mount -t "${fstype}" -o nosuid,nodev "/dev/${devname}" "${NETBOOT_MOUNT}" 2>&1
88 echo "mount of ${devname} failed"
91 common_start "${NETBOOT_MOUNT}/.com.apple.NetBootX" shadowfile
97 mount_from=$(ipconfig netbootoption shadow_mount_path 2>&1)
99 echo "no network shadow mount path available"
102 shadow_path=$(ipconfig netbootoption shadow_file_path 2>&1)
103 if [ $? -ne 0 ]; then
104 echo "no network shadow file path available"
107 case "${mount_from}" in
110 *) echo "unknown network filesystem mount from ${mount_from}"
114 mount -t "${fstype}" "${mount_from}" "${NETBOOT_MOUNT}"
115 if [ $? -ne 0 ]; then
116 echo "mount -t ${fstype} ${mount_from} ${NETBOOT_MOUNT} failed"
119 common_start "${NETBOOT_MOUNT}" "${shadow_path}"
125 case "${NETBOOT_SHADOW}" in
128 if [ $? -ne 0 ]; then
134 if [ $? -ne 0 ]; then
136 if [ $? -ne 0 ]; then
137 Failed "Could not find a local or network drive"
143 if [ $? -ne 0 ]; then
150 if [ $? -ne 0 ]; then
152 if [ $? -ne 0 ]; then
153 Failed "Could not find a network or local drive"
163 # attach the shadow file to the root disk image
166 # make sure the root filesystem is clean
167 fsck -p || fsck -fy || Failed "Could not clean root filesystem"
172 # adjust /private/var/vm to point to the writable area (if not diskless)
173 swapdir=/private/var/vm
174 mounted_from=$(mount | sed -n 's:\(.*\) on .*/var/netboot.*:\1:p')
175 case "${mounted_from}" in
177 netboot_dir
="${NETBOOT_MOUNT}/.com.apple.NetBootX"
178 if [ -d "${netboot_dir}" ]; then
180 ln -s "${netboot_dir}" "${swapdir}"
187 # set the ComputerName based on what the NetBoot server told us it was
188 machine_name
=$(ipconfig netbootoption machine_name 2>&1)
189 if [ $?
-ne 0 ]; then
190 echo "no machine name option available"
192 echo "Setting ComputerName to ${machine_name}"
193 scutil
--set ComputerName
"${machine_name}"
198 if [ $# -lt 1 ] ; then