rc.common, rc.netboot

Could someone please give me the 411 on these two files:

RC.COMMON:

##
# Common setup for startup scripts.
##
# Copyright 1998-2002 Apple Computer, Inc.
##

#######################
# Configure the shell #
#######################

##
# Be strict
##
#set -e
set -u

##
# Set command search path
##
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServices; export PATH

##
# Set the terminal mode
##
#if [ -x /usr/bin/tset ] && [ -f /usr/share/misc/termcap ]; then
# TERM=$(tset - -Q); export TERM
#fi

####################
# Useful functions #
####################

##
# Determine if the network is up by looking for any non-loopback
# internet network interfaces.
##
CheckForNetwork()
{
local test

if [ -z "${NETWORKUP:=}" ]; then
test=$(ifconfig -a inet 2>/dev/null | sed -n -e '/127.0.0.1/d' -e '/0.0.0.0/d' -e '/inet/p' | wc -l)
if [ "${test}" -gt 0 ]; then
NETWORKUP="-YES-"
else
NETWORKUP="-NO-"
fi
fi
}

alias ConsoleMessage=echo

##
# Process management
##
GetPID ()
{
local program="$1"
local pidfile="${PIDFILE:=/var/run/${program}.pid}"
local pid=""

if [ -f "${pidfile}" ]; then
pid=$(head -1 "${pidfile}")
if ! kill -0 "${pid}" 2> /dev/null; then
echo "Bad pid file $pidfile; deleting."
pid=""
rm -f "${pidfile}"
fi
fi

if [ -n "${pid}" ]; then
echo "${pid}"
return 0
else
return 1
fi
}

##
# Generic action handler
##
RunService ()
{
case $1 in
start ) StartService ;;
stop ) StopService ;;
restart) RestartService ;;
* ) echo "$0: unknown argument: $1";;
esac
}

##########################
# Get host configuration #
##########################
. /etc/hostconfig





RC.NETBOOT:


#!/bin/sh
##
# Copyright 2002 Apple Computer, Inc.
#
# This script configures NetBoot
##

. /etc/rc.common

#
# Define: NETBOOT_SHADOW
# Purpose:
# To change the behavior of the system when choosing a netboot shadow
# to use.
# Values:
# -NETWORK- Try to use the network for the shadow file, if
# that fails, use the local drive
# -NETWORK_ONLY- Only use the network, fail if not available
# -LOCAL- Use the local drive for the shadow file, if that
# fails, use the network
# -LOCAL_ONLY- Only use the local drive for the shadow, fail if
# not available

NETBOOT_MOUNT=/var/netboot
NETBOOT_SHADOW=${NETBOOT_SHADOW:-NETWORK-}

Failed()
{
echo rc.netboot: $1
exit 1
}

common_start()
{
netboot_dir=$1
netboot_shadow=$2
if [ "${netboot_dir}" = "" ] ; then
Failed "netboot_dir is empty"
fi
if [ "${netboot_shadow}" = "" ] ; then
Failed "netboot_shadow is empty"
fi
netboot_shadow="${netboot_dir}/${netboot_shadow}"
if ! mkdir -p "${netboot_dir}" ; then
Failed "create ${netboot_dir} failed"
fi
chmod 700 "${netboot_dir}"
mount -u -o ro /
root_device=$(mount | sed -n 's:/dev/\(.*\) on / .*:\1:p')
case "${root_device}" in
vn*)
if ! touch "${netboot_shadow}" ; then
Failed "create ${netboot_shadow} failed"
fi
chmod 600 "${netboot_shadow}"
if ! /usr/libexec/vndevice shadow "/dev/r${root_device}" "${netboot_shadow}" ; then
Failed "vndevice shadow failed"
fi
;;
"")
Failed "root device unknown"
;;
*)
if ! touch "${netboot_shadow}" ; then
Failed "failed to create shadow ${netboot_shadow}"
fi
chmod 600 "${netboot_shadow}"
if ! /usr/bin/nbdst -recycle "${root_device}" "${netboot_shadow}" ; then
Failed "nbdst failed"
fi
;;
esac
}

local_mount()
{
volinfo=`autodiskmount -F 2>/dev/null`
if [ $? -ne 0 ]; then
echo "autodiskmount -F found no local drives"
return 1
fi
set ${volinfo}
devname=$1
fstype=$2

mount -t "${fstype}" -o nosuid,nodev "/dev/${devname}" "${NETBOOT_MOUNT}" 2>&1
if [ $? -ne 0 ]; then
echo "mount of ${devname} failed"
return 1
fi
common_start "${NETBOOT_MOUNT}/.com.apple.NetBootX" shadowfile
return 0
}

network_mount()
{
mount_from=$(ipconfig netbootoption shadow_mount_path 2>&1)
if [ $? -ne 0 ]; then
echo "no network shadow mount path available"
return 1
fi
shadow_path=$(ipconfig netbootoption shadow_file_path 2>&1)
if [ $? -ne 0 ]; then
echo "no network shadow file path available"
return 1
fi
case "${mount_from}" in
afp:*) fstype=afp;;
nfs:*) fstype=nfs;;
*) echo "unknown network filesystem mount from ${mount_from}"
return 1
;;
esac
mount -t "${fstype}" "${mount_from}" "${NETBOOT_MOUNT}"
if [ $? -ne 0 ]; then
echo "mount -t ${fstype} ${mount_from} ${NETBOOT_MOUNT} failed"
return 1
fi
common_start "${NETBOOT_MOUNT}" "${shadow_path}"
return 0
}

do_start()
{
case "${NETBOOT_SHADOW}" in
-LOCAL_ONLY-)
err=$(local_mount)
if [ $? -ne 0 ]; then
Failed "${err}"
fi
;;
-LOCAL-)
err=$(local_mount)
if [ $? -ne 0 ]; then
err=$(network_mount)
if [ $? -ne 0 ]; then
Failed "Could not find a local or network drive"
fi
fi
;;
-NETWORK_ONLY-)
err=$(network_mount)
if [ $? -ne 0 ]; then
Failed "${err}"
fi
;;

*)
err=$(network_mount)
if [ $? -ne 0 ]; then
err=$(local_mount)
if [ $? -ne 0 ]; then
Failed "Could not find a network or local drive"
fi
fi
;;
esac

}

do_init()
{
# attach the shadow file to the root disk image
do_start

# make sure the root filesystem is clean
fsck -p || fsck -fy || Failed "Could not clean root filesystem"

# make it writable
mount -uw /

# adjust /private/var/vm to point to the writable area (if not diskless)
swapdir=/private/var/vm
mounted_from=$(mount | sed -n 's:\(.*\) on .*/var/netboot.*:\1:p')
case "${mounted_from}" in
/dev/*)
netboot_dir="${NETBOOT_MOUNT}/.com.apple.NetBootX"
if [ -d "${netboot_dir}" ]; then
rm -rf "${swapdir}"
ln -s "${netboot_dir}" "${swapdir}"
fi
;;
*)
;;
esac

# set the ComputerName based on what the NetBoot server told us it was
machine_name=$(ipconfig netbootoption machine_name 2>&1)
if [ $? -ne 0 ]; then
echo "no machine name option available"
else
echo "Setting ComputerName to ${machine_name}"
scutil --set ComputerName "${machine_name}"
fi
}


if [ $# -lt 1 ] ; then
exit 0
fi

command=$1

shift

case "${command}" in
init)
do_init $@
;;
esac

##
# Exit
##
exit 0

Message was edited by: pianoman1976

iMac 2.4 GHz Intel Core 2 Duo, 4 GB SDRAM, Mac OS X (10.5.6)

Posted on Jan 3, 2009 11:11 AM

Reply
4 replies

Jan 3, 2009 11:28 AM in response to pianoman1976

Don't be concerned. It's only used if you are attempting to boot the computer using netboot. If not, the script is inactive. Don't mess with them. In fact there's no reason for you to be concerned with what's installed in the OS X hidden folders. Those are all part of the Unix system used by OS X. There's a good reason why the folders are hidden.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

rc.common, rc.netboot

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.