From 629d443f5aa61eaf8d41c066011108e2b3b9caa1 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Fri, 25 Oct 2019 01:40:48 +0200 Subject: [PATCH] [__hostname] Fix "command not found" errors with old Bash --- cdist/conf/type/__hostname/explorer/has_hostnamectl | 2 +- cdist/conf/type/__hostname/explorer/max_len | 2 +- cdist/conf/type/__hostname/explorer/persistent_hostname | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__hostname/explorer/has_hostnamectl b/cdist/conf/type/__hostname/explorer/has_hostnamectl index 9040023d..2f531f30 100755 --- a/cdist/conf/type/__hostname/explorer/has_hostnamectl +++ b/cdist/conf/type/__hostname/explorer/has_hostnamectl @@ -21,4 +21,4 @@ # Check whether system has hostnamectl # -command -v hostnamectl || true +command -v hostnamectl 2>/dev/null || true diff --git a/cdist/conf/type/__hostname/explorer/max_len b/cdist/conf/type/__hostname/explorer/max_len index 97d8a142..fb863949 100644 --- a/cdist/conf/type/__hostname/explorer/max_len +++ b/cdist/conf/type/__hostname/explorer/max_len @@ -2,7 +2,7 @@ command -v getconf >/dev/null || exit 0 -val=$(getconf HOST_NAME_MAX 2>/dev/null) +val=$(getconf HOST_NAME_MAX 2>/dev/null) || exit 0 if test -n "${val}" -a "${val}" != 'undefined' then diff --git a/cdist/conf/type/__hostname/explorer/persistent_hostname b/cdist/conf/type/__hostname/explorer/persistent_hostname index 141c44fe..0feb0809 100755 --- a/cdist/conf/type/__hostname/explorer/persistent_hostname +++ b/cdist/conf/type/__hostname/explorer/persistent_hostname @@ -22,7 +22,7 @@ # # Firstly, check hostnamectl if available. -if command -v hostnamectl >/dev/null +if command -v hostnamectl >/dev/null 2>&1 then hostnamectl status --static && exit 0 fi @@ -32,10 +32,10 @@ fi case $("$__explorer/os") in alpine|archlinux|coreos|debian|devuan|ubuntu) - [ -f /etc/hostname ] && cat /etc/hostname + test -f /etc/hostname && cat /etc/hostname ;; centos|fedora|redhat|scientific) - [ -f /etc/sysconfig/network ] \ + test -f /etc/sysconfig/network \ && (. /etc/sysconfig/network && echo "$HOSTNAME") ;; freebsd)