Posted on 09-16-2011 09:02 AM
Hi List,
I'm not much of a scripter and pieced this together from the resource kit
and google. It sets the computer name to a prefix and the last six digits of
the serial number. I'm wondering what, if any, precautions I should take
before turning this loose. Or if there is a better way to enforce the
computer name.
Thanks,
-- jmca
#!/bin/sh
computerName=""
# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4 AND, IF SO, ASSIGN TO
"computerName"
# ELSE SET "computerName" TO WHATEVER THE COMPUTER IS CURRENTLY NAMED
if [ "$4" != "" ] && [ "$computerName" == "" ];then
computerName=$4
else
computerName=/usr/sbin/systemsetup -getcomputername | awk '{print $3}'
fi
companyComputerName=`system_profiler | grep "r (system)" | awk '{ print $4}'
| sed 's/^.{5}/NYC/g'`
####################################################################################################
#
# SCRIPT CONTENTS - DO NOT MODIFY BELOW THIS LINE
#
####################################################################################################
if [ "$companyComputerName" != "$computerName" ]; then
echo "This computer has a bad name ;-)"
/usr/sbin/systemsetup -setcomputername $companyComputerName
else
echo "Computer Name is correct."
fi