set-names.sh

code format="text" PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
 * 1) !/bin/sh


 * 1) set-names.sh ############################
 * 2) Mike Bombich | mike@bombich.com
 * 3) Copyright 2003-2008 Mike Bombich
 * 4) This is a lab machine post-installation customization script for
 * 5) use with NetRestore: http://www.bombich.com/software/netrestore.html


 * 1) Description ###
 * 2) This script will set the Computer name and Rendezvous name
 * 3) (as seen in the Sharing Preference Pane)
 * 4) Note that the Rendezvous name is very picky -- don't use any
 * 5) spaces or special characters and it can't start with a number.
 * 6) Also remember that the name of the target disk is passed to
 * 7) the post-action script as an argument ("$1" -- always use quotes!)
 * 1) the post-action script as an argument ("$1" -- always use quotes!)

paDir=`dirname "$0"` nameTable="$paDir"/../Preferences/machine_specific_data.csv
 * 1) Properties ###
 * 2) These items must be modified to suit your environment before
 * 3) implementing this script! You do not need to make any other
 * 4) modifications to this file than these properties.
 * 5) The name table is a Comma Separated Value (.csv) file that contains
 * 6) a list of hardware addresses (without colons) and their associated names
 * 7) Note that you don't have to use the name table approach, you could simply use the
 * 8) hardware address if all you needed was a unique name.
 * 9) nameTable: path to the machine_specific_data file
 * 10) If you do not move the machine_specific_data.csv file (that is, you
 * 11) leave it in the Resources/Preferences directory and do not rename it),
 * 12) then you do not need to modify the paDir and nameTable variables.
 * 1) leave it in the Resources/Preferences directory and do not rename it),
 * 2) then you do not need to modify the paDir and nameTable variables.


 * 1) Script action ###

swVers=`defaults read "$1"/System/Library/CoreServices/SystemVersion ProductVersion | awk -F. '{print $2}'` if [ $swVers -ge 3 ]; then SC="Library/Preferences/SystemConfiguration/preferences.plist" else SC="private/var/db/SystemConfiguration/preferences.xml" fi
 * 1) Determine the OS of the target system and set the path of the SC file accordingly

echo "This system's SystemConfiguration preference file is located at:" echo "$1"/$SC echo ""

hwAddress=`ifconfig en0 | awk '/ether/ { gsub(":", ""); print $2 }'`

echo "This computer's hardware address is: $hwAddress" echo "This computer's name_table.csv record is:" echo `cat "$nameTable" | grep $hwAddress` echo ""
 * 1) Print out this computer's record for reference

computerName=`cat "$nameTable" | awk -F, "/$hwAddress/ "'{ print $2 }'` rendezvousName=`cat "$nameTable" | awk -F, "/$hwAddress/ "'{ print $3 }'`
 * 1) Determine the names (look them up in a table of hardware addresses and names)

if [ "$computerName" == "" ]; then computerName=$hwAddress fi
 * 1) Provide a default name if the hardware address is not listed in the name table

if [ "$rendezvousName" == "" ]; then rendezvousName="HW-$hwAddress" fi

echo "post-action:STATUS:Setting computer and Rendezvous names" echo "Computer Name: $computerName" echo "Rendezvous Name: $rendezvousName" "$paDir"/bin/SetHostNames "$1"/$SC "$computerName" "$rendezvousName"
 * 1) Set the names using the "SetHostNames" application provided with NetRestore

code

--1233508818