}
-do_computername()
+do_init()
{
- 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
-}
+ # attach the shadow file to the root disk image
+ do_start
-do_vm()
-{
- swapdir=${1:-/private/var/vm}
+ # make sure the root filesystem is clean
+ fsck -p || fsck -fy || Failed "Could not clean root filesystem"
- mounted_from=$(mount | sed -n 's:\(.*\) on .*/var/netboot.*:\1:p')
+ # 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 "${netboot_dir}/app_profile"
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
shift
case "${command}" in
- start)
- do_start $@
- ;;
- setup_vm)
- do_vm $@
- ;;
- setup_computername)
- do_computername $@
+ init)
+ do_init $@
;;
esac