#!/bin/sh
# $Id: osx-set-hostname,v 1.2 2016/10/12 22:23:02 friedman Exp $

plbset()
{
    /usr/libexec/PlistBuddy -c "set $1 $2" "${3-/Library/Preferences/SystemConfiguration/preferences.plist}"
}

fqdn=$1
host=${1%%.*}

plbset :System:System:HostName                 "$fqdn"
plbset :System:System:ComputerName             "$host"
plbset :System:Network:HostNames:LocalHostName "$host"

networksetup -setcomputername "$fqdn"

# eof
