Created
January 9, 2012 01:49
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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