Last active
August 29, 2015 13:57
-
-
Save audibleblink/9879960 to your computer and use it in GitHub Desktop.
Sets hostname on DBC machines
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
cd /usr/local/opt/kitout/set-host-name/ | |
unit_dir=$(cd $(dirname $0); pwd) | |
# Get this machine's mac address | |
mac_address=`ifconfig en0 | grep '\bether\b' | sed 's/.ether //'` | |
# Look up it's machine number | |
host_num=`cat $unit_dir/host-numbers-to-mac-addresses | grep '^\d' | grep $mac_address | cut -d ' ' -f 1` | |
test $host_num || { | |
echo "Skipping" | |
exit | |
} | |
# Set the host name based on the machine number. scutil so it persists. | |
sudo scutil --set ComputerName "dbc${host_num}" | |
sudo scutil --set HostName "dbc${host_num}" | |
sudo scutil --set LocalHostName "dbc${host_num}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment