Files
runner-images/images/macos/scripts/build/configure-hostname.sh
Alexey-Ayupov 5a6e215859 [macOS] Refactor the rest of the scripts (#9113)
* [macOS] Refactor the rest of the scripts

* Return quotes to config tccdb script

* Return quotes to config tccdb script

* Revert some changes in ruby scripts

* Revert some changes in ruby scripts

* Revert some changes chrome script

* check errors

* check errors 01

* find errors in common-utils

* find errors in edge install

* find errors in edge install

---------

Co-authored-by: Alexey Ayupov <“alexey.ayupov@akvelon.com”>
2024-01-09 14:47:31 +01:00

33 lines
1.2 KiB
Bash

#!/bin/bash -e -o pipefail
################################################################################
## File: configure-hostname.sh
## Desc: Change the hostname at startup to prevent duplicates
## 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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>change-hostname</string>
<key>Program</key>
<string>/usr/local/bin/change_hostname.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF