[__hostame] Resolve shellcheck errors
This commit is contained in:
parent
d4313c7501
commit
b65ceba569
2 changed files with 6 additions and 6 deletions
|
@ -59,14 +59,14 @@ echo 'changed' >> "$__messages_out"
|
||||||
|
|
||||||
|
|
||||||
# First try to set the hostname using hostnamectl, if available.
|
# First try to set the hostname using hostnamectl, if available.
|
||||||
if [ "$has_hostnamectl" ]; then
|
if [ -n "$has_hostnamectl" ]; then
|
||||||
# Allow hostnamectl to fail silently.
|
# Allow hostnamectl to fail silently.
|
||||||
# Who the fuck invented a tool that needs dbus to set the hostname anyway…
|
# Who the fuck invented a tool that needs dbus to set the hostname anyway…
|
||||||
|
|
||||||
# NOTE: We write the static hostname to /etc/hostname first in case
|
# NOTE: We write the static hostname to /etc/hostname first in case
|
||||||
# hostnamectl fails. Fallback-code below will then adjust the running
|
# hostnamectl fails. Fallback-code below will then adjust the running
|
||||||
# hostname below.
|
# hostname below.
|
||||||
echo "printf '%s\\n' '$name_should' > /etc/hostname"
|
echo "echo '$name_should' >/etc/hostname"
|
||||||
|
|
||||||
echo "hostnamectl set-hostname '$name_should' && exit 0"
|
echo "hostnamectl set-hostname '$name_should' && exit 0"
|
||||||
fi
|
fi
|
||||||
|
@ -75,7 +75,7 @@ fi
|
||||||
case $os
|
case $os
|
||||||
in
|
in
|
||||||
alpine|archlinux|debian|devuan|ubuntu)
|
alpine|archlinux|debian|devuan|ubuntu)
|
||||||
echo "printf '%s\\n' '$name_should' > /etc/hostname"
|
echo "echo '$name_should' >/etc/hostname"
|
||||||
echo "hostname -F /etc/hostname"
|
echo "hostname -F /etc/hostname"
|
||||||
;;
|
;;
|
||||||
coreos|openbmc-phosphor)
|
coreos|openbmc-phosphor)
|
||||||
|
@ -95,7 +95,7 @@ in
|
||||||
suse)
|
suse)
|
||||||
# We write into /etc/HOSTNAME for backwards-compatibility. Modern SuSE
|
# We write into /etc/HOSTNAME for backwards-compatibility. Modern SuSE
|
||||||
# has hostnamectl anyway and symlinks /etc/HOSTNAME to /etc/hostname.
|
# has hostnamectl anyway and symlinks /etc/HOSTNAME to /etc/hostname.
|
||||||
echo "printf '%s\\n' '$name_should' > /etc/HOSTNAME"
|
echo "echo '$name_should' >/etc/HOSTNAME"
|
||||||
echo 'hostname -F /etc/HOSTNAME'
|
echo 'hostname -F /etc/HOSTNAME'
|
||||||
;;
|
;;
|
||||||
centos|fedora|freebsd|netbsd|openbsd|redhat|scientific)
|
centos|fedora|freebsd|netbsd|openbsd|redhat|scientific)
|
||||||
|
|
|
@ -47,7 +47,7 @@ else
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -n "${max_len}" -a "$(printf "${name_should}" | wc -c)" -gt "${max_len}"
|
if test -n "${max_len}" -a "$(printf '%s' "${name_should}" | wc -c)" -gt "${max_len}"
|
||||||
then
|
then
|
||||||
printf "Host name too long. Up to %u characters allowed.\n" "${max_len}" >&2
|
printf "Host name too long. Up to %u characters allowed.\n" "${max_len}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in a new issue