diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index 973d1d97..b258165d 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -29,7 +29,8 @@ has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl") if [ -f "$__object/parameter/name" ]; then name_should="$(cat "$__object/parameter/name")" else - case $os in + case $os + in # RedHat-derivatives and BSDs centos|fedora|redhat|scientific|freebsd|netbsd|openbsd) # Hostname is FQDN @@ -45,14 +46,16 @@ fi ################################################################################ # Check if the hostname is already correct # -if [ "$name_running" = "$name_should" ] && [ ! "$name_config" -o "$name_config" = "$name_should" ]; then +if [ "$name_running" = "$name_should" ] \ + && [ -z "$name_config" -o "$name_config" = "$name_should" ] +then exit 0 fi ################################################################################ # Setup hostname # -echo changed >> "$__messages_out" +echo 'changed' >> "$__messages_out" # First try to set the hostname using hostnamectl, if available. @@ -69,7 +72,8 @@ EOF fi # Use the good old way to set the hostname. Also if hostnamectl fails. -case $os in +case $os +in archlinux|debian|ubuntu|devuan|coreos|alpine) printf "printf '%%s\\\\n' '$name_should' > /etc/hostname\\n" echo "hostname -F /etc/hostname" diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index 699f3e93..18152c3e 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -24,7 +24,8 @@ os=$(cat "$__global/explorer/os") if [ -f "$__object/parameter/name" ]; then name_should="$(cat "$__object/parameter/name")" else - case $os in + case $os + in # RedHat-derivatives and BSDs centos|fedora|redhat|scientific|freebsd|netbsd|openbsd) # Hostname is FQDN @@ -44,7 +45,8 @@ not_supported() { exit 1 } -case "$os" in +case $os +in archlinux|debian|suse|ubuntu|devuan|coreos|alpine|macosx) # handled in gencode-remote :