From f276813f7f1fe0af7775bb41adf37dcd3d377992 Mon Sep 17 00:00:00 2001
From: Dennis Camera <dennis.camera@ssrq-sds-fds.ch>
Date: Sat, 26 Oct 2019 17:25:44 +0200
Subject: [PATCH] [__hostname] Remove incorrectly sent messages (again)

The --onchage sent the message on the target where messaging is not supported.

Now the result is that a "changed" message is only emitted when the running
hostname changes, not when the persistent hostname changes.
---
 cdist/conf/type/__hostname/manifest | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest
index 78adc20b..49591926 100755
--- a/cdist/conf/type/__hostname/manifest
+++ b/cdist/conf/type/__hostname/manifest
@@ -20,8 +20,6 @@
 # along with cdist. If not, see <http://www.gnu.org/licenses/>.
 #
 
-onchange_cmd="echo changed >>'$__messages_out'"
-
 not_supported() {
     echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
     echo "Please contribute an implementation for it if you can." >&2
@@ -29,7 +27,7 @@ not_supported() {
 }
 
 set_hostname_systemd() {
-    echo "$1" | __file /etc/hostname --source - --onchange "$onchange_cmd"
+    echo "$1" | __file /etc/hostname --source -
 }
 
 os=$(cat "$__global/explorer/os")
@@ -64,7 +62,7 @@ case $os
 in
     alpine|debian|devuan|ubuntu)
         echo "$name_should" \
-            | __file /etc/hostname --source - --onchange "$onchange_cmd"
+            | __file /etc/hostname --source -
     ;;
     macosx)
         # handled in gencode-remote
@@ -81,8 +79,7 @@ in
                 --file /etc/rc.conf \
                 --delimiter '=' --exact_delimiter \
                 --key 'HOSTNAME' \
-                --value "\"$name_should\"" \
-                --onchange "$onchange_cmd"
+                --value "\"$name_should\""
         fi
         ;;
     centos|fedora|redhat|scientific)
@@ -94,8 +91,7 @@ in
                 --file /etc/sysconfig/network \
                 --delimiter '=' --exact_delimiter \
                 --key HOSTNAME \
-                --value "\"$name_should\"" \
-                --onchange "$onchange_cmd"
+                --value "\"$name_should\""
         else
             set_hostname_systemd "$name_should"
         fi
@@ -119,29 +115,27 @@ in
             --file /etc/rc.conf \
             --delimiter '=' --exact_delimiter \
             --key 'hostname' \
-            --value "\"$name_should\"" \
-            --onchange "$onchange_cmd"
+            --value "\"$name_should\""
     ;;
     netbsd)
         __key_value rcconf-hostname \
             --file /etc/rc.conf \
             --delimiter '=' --exact_delimiter \
             --key 'hostname' \
-            --value "\"$name_should\"" \
-            --onchange "$onchange_cmd"
+            --value "\"$name_should\""
 
         # To avoid confusion, ensure that the hostname is only stored once
         __file /etc/myname --state absent
     ;;
     openbsd)
         echo "$name_should" \
-            | __file /etc/myname --source - --onchange "$onchange_cmd"
+            | __file /etc/myname --source -
     ;;
     suse)
         # We write into /etc/HOSTNAME for backwards-compatibility.  Modern SuSE
         # has hostnamectl anyway and symlinks /etc/HOSTNAME to /etc/hostname.
         echo "$name_should" \
-            | __file /etc/HOSTNAME --source - --onchange "$onchange_cmd"
+            | __file /etc/HOSTNAME --source -
     ;;
     *)
         # On other operating systems we fall back to systemd's hostnamectl if available…