I have a TSV that lists all the computer names I hope to set with their associated WiFi MAC Address setup like so:
Computer Name MAC Address
Class-LastName-FirstName 0123456789ABCD
I am not sure how to script this but I am hoping to get the devices MAC address, find the correct name in the list, then set the Computer Name, Host Name, Local DNS name and the "Student" accounts long name as that value. (The current user is "Student" located at /Users/student. I don't want to change it's short name or location, just the "Full Name")
Does anyone know how best to do this? It may have to be built as a package then pushed out. I do know it will need to look something like this and then add the user account section.
#!/bin/sh
##
# Will set ComputerName LocalHost and DNS Name, macaddressnames.txt must be Unicode/Unix(LF)
##
. /etc/rc.common
ConsoleMessage "Setting Computer Name"
#Define where the macaddressnames text file will be located.
macadnames="/Library/renamer/macaddressnames.txt"
#Execute if the macaddressnames file exists
if [ -e $macadnames ]; then
#Get WIFI Mac address
myairportid=`/sbin/ifconfig en0 | grep -i ether | cut -f2 -d' ' | sed 's/://g'`
#Search macaddressnames file for the WIFI Address and find the computer name
mycname=`grep $macadnames -i -e$myairportid | cut -f2`
#Search macaddressnames file for the WIFI Address and find the DNS name
myrname=`grep $macadnames -i -e$myairportid | cut -f3`
fi
#Rename the Computer
scutil --set ComputerName "$mycname"
scutil --set LocalHostName $myrname
scutil --set HostName $myrname
dscacheutil -flushcache