Skip to content

Instantly share code, notes, and snippets.

@acidprime
Created January 9, 2012 01:49
Show Gist options
  • Save acidprime/1580528 to your computer and use it in GitHub Desktop.
Save acidprime/1580528 to your computer and use it in GitHub Desktop.
Check hostname is less then 15 , Apple Remote Desktop issues with Rename computers option and AD
#!/bin/bash
awk=/usr/bin/awk
ifconfig=/sbin/ifconfig
scutil=/usr/sbin/scutil
COMPUTER_NAME=`$scutil --get ComputerName`
LOCAL_HOST_NAME=`$scutil --get LocalHostName`
MAC_ADDRESS=`$ifconfig en0 ether | $awk '/ether/{gsub(":","",$NF);print $NF}'`
if [ "${#COMPUTER_NAME}" -gt 15 ] ; then
echo "Computer Name is greater then 15!"
if [ "${#LOCAL_HOST_NAME}" -gt 15 ] ; then
echo "Local HostName is also Greater then 15!"
echo "Resetting to MAC Address"
$scutil --set ComputerName "$MAC_ADDRESS"
sleep 1
$scutil --set LocalHostName "${MAC_ADDRESS}"
fi
else
sleep 1
echo "Computer Name is less then 15"
if [ "${#LOCAL_HOST_NAME}" -gt 15 ] ; then
$scutil --set LocalHostName "$COMPUTER_NAME"
else
echo "LocalHostName is less then 15"
fi
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment