From ee440ec61996b53889dff3327d1fd4c4fa0f2a57 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Thu, 3 Oct 2019 21:41:51 +0200 Subject: [PATCH] [__hostname] Compress state check --- cdist/conf/type/__hostname/gencode-remote | 29 +++++++++-------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index ee12f822..c6779a22 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -33,25 +33,18 @@ name_sysconfig=$(cat "$__object/explorer/hostname_sysconfig") has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl") ################################################################################ -# If everything is ok -> exit +# Check if the hostname is already correct # -case "$os" in - archlinux|debian|suse|ubuntu|devuan|coreos|alpine) - if [ "$name_config" = "$name_should" ] && [ "$name_running" = "$name_should" ]; then - exit 0 - fi - ;; - scientific|centos|freebsd|openbsd) - if [ "$name_sysconfig" = "$name_should" ] && [ "$name_running" = "$name_should" ]; then - exit 0 - fi - ;; - *) - if [ "$name_running" -a "$name_running" = "$name_should" ]; then - exit 0 - fi - ;; -esac +if [ "$name_running" = "$name_should" ]; then + case "$os" in + archlinux|debian|suse|ubuntu|devuan|coreos|alpine) + [ "$name_config" != "$name_should" ] || exit 0 + ;; + scientific|centos|freebsd|openbsd) + [ "$name_sysconfig" != "$name_should" ] || exit 0 + ;; + esac +fi ################################################################################ # Setup hostname