Skip to content

Commit

Permalink
ComputerName to HostName
Browse files Browse the repository at this point in the history
  • Loading branch information
sphen13 committed Jan 18, 2018
1 parent 3dd89be commit 7cd6af4
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ComputerName to HostName/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# .DS_Store files!
.DS_Store

# our build directory
build/
22 changes: 22 additions & 0 deletions ComputerName to HostName/build-info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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>distribution_style</key>
<false/>
<key>identifier</key>
<string>com.github.sphen13.computernametohostname</string>
<key>install_location</key>
<string>/</string>
<key>name</key>
<string>ComputerName to HostName-${version}.pkg</string>
<key>ownership</key>
<string>recommended</string>
<key>postinstall_action</key>
<string>none</string>
<key>suppress_bundle_relocation</key>
<true/>
<key>version</key>
<string>1.1</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>computer-to-hostname</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Scripts/computer-to-hostname.sh</string>
</array>
<key>StartInterval</key>
<integer>43200</integer>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

new_name=`networksetup -getcomputername | sed -e "s/[+=., \"'()]//g"`

echo "Setting Local DNS Name to: $new_name"
scutil --set LocalHostName $new_name
echo "Setting HostName Name to: $new_name"
scutil --set HostName $new_name

exit 0
8 changes: 8 additions & 0 deletions ComputerName to HostName/scripts/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
## postinstall

# reload
launchctl unload /Library/LaunchDaemons/computer-to-hostname.plist
launchctl load -w /Library/LaunchDaemons/computer-to-hostname.plist

exit 0

0 comments on commit 7cd6af4

Please sign in to comment.