Mac OS X: 实用脚本程序(bash scripts)系列-5

设置Mac OS X 10.5 Leopard打开NetBoot服务

注:

无论是Mac OS X: 实用脚本程序(bash scripts)系列-4 ,还是这里的脚本,都是在默认的当前系统的根/下面设置NetBoot的,也就是在/Library/NetBoot目录里面,通过修改可以变更这个目录到其它的分区/盘的其它目录中。

 

简单介绍NetBoot服务,NetBoot/NetInstall服务用于网络启动Mac电脑/安装Mac系统的服务,它的启动功能如同无盘工作站,而安装可以即时网络更新客户端的Mac操作系统。

 

#!/bin/bash
#This script sets up netbooting on a Leopard (Client) machine.


# START WITH SOME SANITY CHECKS
# -----------------------------

# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
        echo "You must run this script as the root user.  (Try /"sudo $0/")"
        exit 1
fi;

# check that this is Mac OS X Leopard (Client)
if [[ "`sw_vers -productName`" != "Mac OS X" ]] || [[ "`sw_vers -productVersion`" < "10.5" ]]; then
        echo "The script is designed to be run on Mac OS X Leopard, on a non-server version."
        exit 2
fi;

echo "Make sure Internet Sharing is turned OFF Before continuing! (System Preferences > Sharing)
Press Enter to continue."
read junk

# CREATE DIRECTORIES AND SIMLINKS NEEDED FOR NETBOOTING
# -----------------------------------------------------

mkdir -p /Library/NetBoot/NetBootSP0
mkdir /Library/NetBoot/NetBootClients0
chown root:admin /Library/NetBoot/NetBoot*
chmod 775 /Library/NetBoot/NetBoot*

cd /Library/NetBoot
ln -s NetBootSP0 /Library/NetBoot/.sharepoint
ln -s NetBootClients0 /Library/NetBoot/.clients

# EXPORT NETBOOTING FOLDERS OVER NFS (NETWORK FILE SYSTEM)
# --------------------------------------------------------

echo "/Library/NetBoot/NetBootSP0 -ro" >> /etc/exports
# Note that as soon as the file changes, the OS restarts the NFS daemon

# CREATE DIRECTORIES AND SIMLINKS NEEDED FOR NETBOOTING
# --------------------------------Boot
ln -s /Library/NetBoot /private/tftpboot/NetBoot
service tftp start

# SET UP BSDP (BOOT SERVICE DISCOVERY PROTOCOL)
# ---------------------------------------------

# Create the /etc/bootpd.plist file.

# This file below is based on information from the bootpd man page.

echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>bootp_enabled</key>
        <string>en0</string>
        <key>netboot_enabled</key>
        <string>en0</string>
        <key>old_netboot_enabled</key>
        <string>en0</string>
</dict>
</plist>' > /etc/bootpd.plist

service bootps start


# WE ARE FINISHED
# ---------------

echo "NetBoot setup script complete. Please make sure to add the NetBootSP0 and NetBootClients0 folders to your Shared Folders (System Preferences > Sharing > File Sharing)."

 


原文链接: http://blog.csdn.net/afatgoat/article/details/4321389

你可能感兴趣的:(Mac OS X: 实用脚本程序(bash scripts)系列-5)