Hello,

We have recently "lost" the Built-in preinstallation and postinstall scrips to collect and apply the computer name when re-imaging an apple system.

could some link me to a support page to recreat it please?

Thank you!

 

0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answers

0

Collect Mac OS X Computer Name:

#!/bin/bash

 

MAC=`/usr/sbin/networksetup -getmacaddress Ethernet 2> /dev/null | awk ' { print $3; }' | sed -e s/://g `

 

TEMP_PATH="/opt/kace/petemp/${MAC}"

 

IFS=$'\n'

volume=`mount | grep -m 1 disk0`

zeroMount=`echo "$volume" | awk  '{  print substr($0,index($0, "on ")+3,index($0, "(")-index($0, "on ")-4) }'`

 

prefPath=${KACE_SYSTEM_DRIVE_PATH}/Library/Preferences/SystemConfiguration/preferences.plist

 

tComputerName=`/usr/libexec/PlistBuddy -c "Print System:System:ComputerName" $prefPath` 

computerName=`echo $tComputerName | awk '{ print index($0,"Not Exist") }'`

if [ x$computerName == x0 ]; then

   computerName=$tComputerName

else 

   computerName="localhost"

fi

 

echo $computerName > "${TEMP_PATH}"

 

exit 0
 
Apply Mac OS X Computer Name:
 
#!/bin/bash
 
MAC=`/usr/sbin/networksetup -getmacaddress Ethernet 2> /dev/null | awk ' { print $3; }' | sed -e s/://g `
 
TEMP_PATH="/opt/kace/petemp/${MAC}"
 
if [ -f "${TEMP_PATH}" ] 
then
    COMPNAME=`cat ${TEMP_PATH}`
    echo "Computer name is going to be ${COMPNAME}"
    /usr/libexec/PlistBuddy -c "Set :System:Network:HostNames:LocalHostName ${COMPNAME}" "${KACE_SYSTEM_DRIVE_PATH}/Library/Preferences/SystemConfiguration/preferences.plist"
    /usr/libexec/PlistBuddy -c "Set :System:System:ComputerName ${COMPNAME}" "${KACE_SYSTEM_DRIVE_PATH}/Library/Preferences/SystemConfiguration/preferences.plist"
   /bin/rm "${TEMP_PATH}"
fi
 
exit 0
Answered 07/25/2013 by: dugullett
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity