From cbae534af58859da299972b95d9f5c05040c33e5 Mon Sep 17 00:00:00 2001
From: Dennis Camera <dennis.camera@ssrq-sds-fds.ch>
Date: Sat, 26 Oct 2019 21:01:54 +0200
Subject: [PATCH] [__hostname] Patch for modern ArchLinux without hostname(1)

---
 cdist/conf/type/__hostname/gencode-remote | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote
index 253bf5ea..6840ca9e 100755
--- a/cdist/conf/type/__hostname/gencode-remote
+++ b/cdist/conf/type/__hostname/gencode-remote
@@ -61,7 +61,12 @@ in
     alpine|debian|devuan|ubuntu)
         echo 'hostname -F /etc/hostname'
     ;;
-    archlinux|centos|fedora|redhat|scientific|freebsd|netbsd|gentoo)
+    archlinux)
+        echo 'command -v hostnamectl >/dev/null 2>&1' \
+            "&& hostnamectl set-hostname '$name_should'" \
+            "|| hostname '$name_should'"
+    ;;
+    centos|fedora|redhat|scientific|freebsd|netbsd|gentoo)
         echo "hostname '$name_should'"
     ;;
     macosx)