diff --git a/cdist/conf/type/__hostname/explorer/hostname b/cdist/conf/type/__hostname/explorer/hostname index aaaa3a30..0b562d11 100644 --- a/cdist/conf/type/__hostname/explorer/hostname +++ b/cdist/conf/type/__hostname/explorer/hostname @@ -41,7 +41,7 @@ elif [ -f /etc/myname ]; then elif [ "$(uname -s)" == FreeBSD ]; then (. /etc/rc.conf && echo $hostname) # Mac OS X -elif [ "$(uname -s)" == Darwin -a -f "$(command -v scutil)" ]; then +elif [ "$(uname -s)" == Darwin -a -x "$(command -v scutil)" ]; then scutil --get HostName 2>/dev/null || hostname -s else command -v hostname && hostname -s diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index 20de7078..ee12f822 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -86,6 +86,9 @@ case "$os" in echo "hostname '$name_should'" printf "printf '%%s\\\\n' '$name_should' > /etc/HOSTNAME\\n" ;; + macosx) + echo "scutil --set HostName '$name_should'" + ;; *) echo "echo 'Unsupported OS: $os' >&2; exit 1" ;; diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index 5ea3b8ff..fe067718 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -42,7 +42,7 @@ not_supported() { } case "$os" in - archlinux|debian|suse|ubuntu|devuan|coreos|alpine) + archlinux|debian|suse|ubuntu|devuan|coreos|alpine|macosx) # handled in gencode-remote : ;;