forked from ungleich-public/cdist
[__hostname] Fix "command not found" errors with old Bash
This commit is contained in:
parent
c3b066c147
commit
629d443f5a
3 changed files with 5 additions and 5 deletions
|
@ -21,4 +21,4 @@
|
||||||
# Check whether system has hostnamectl
|
# Check whether system has hostnamectl
|
||||||
#
|
#
|
||||||
|
|
||||||
command -v hostnamectl || true
|
command -v hostnamectl 2>/dev/null || true
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
command -v getconf >/dev/null || exit 0
|
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'
|
if test -n "${val}" -a "${val}" != 'undefined'
|
||||||
then
|
then
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
# Firstly, check hostnamectl if available.
|
# Firstly, check hostnamectl if available.
|
||||||
if command -v hostnamectl >/dev/null
|
if command -v hostnamectl >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
hostnamectl status --static && exit 0
|
hostnamectl status --static && exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -32,10 +32,10 @@ fi
|
||||||
case $("$__explorer/os")
|
case $("$__explorer/os")
|
||||||
in
|
in
|
||||||
alpine|archlinux|coreos|debian|devuan|ubuntu)
|
alpine|archlinux|coreos|debian|devuan|ubuntu)
|
||||||
[ -f /etc/hostname ] && cat /etc/hostname
|
test -f /etc/hostname && cat /etc/hostname
|
||||||
;;
|
;;
|
||||||
centos|fedora|redhat|scientific)
|
centos|fedora|redhat|scientific)
|
||||||
[ -f /etc/sysconfig/network ] \
|
test -f /etc/sysconfig/network \
|
||||||
&& (. /etc/sysconfig/network && echo "$HOSTNAME")
|
&& (. /etc/sysconfig/network && echo "$HOSTNAME")
|
||||||
;;
|
;;
|
||||||
freebsd)
|
freebsd)
|
||||||
|
|
Loading…
Reference in a new issue