#!/bin/bash -e -o pipefail # Add script for changing hostname to run on startup to prevent duplicate hostnames across the environment. Hostname and Computername should contain .local in name to avoid name resolution issues tee -a /usr/local/bin/change_hostname.sh > /dev/null <<\EOF #!/bin/bash -e -o pipefail name="Mac-$(python3 -c 'from time import time; print(int(round(time() * 1000)))')" scutil --set HostName "${name}.local" scutil --set LocalHostName $name scutil --set ComputerName "${name}.local" EOF chmod +x "/usr/local/bin/change_hostname.sh" sudo tee -a /Library/LaunchDaemons/change_hostname.plist > /dev/null <<\EOF Label change-hostname Program /usr/local/bin/change_hostname.sh RunAtLoad EOF