[__hostname] Lint

This commit is contained in:
Dennis Camera 2019-10-06 18:36:43 +02:00
parent cbb108d61c
commit 6e1a105c22
2 changed files with 12 additions and 6 deletions

View File

@ -29,7 +29,8 @@ has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl")
if [ -f "$__object/parameter/name" ]; then if [ -f "$__object/parameter/name" ]; then
name_should="$(cat "$__object/parameter/name")" name_should="$(cat "$__object/parameter/name")"
else else
case $os in case $os
in
# RedHat-derivatives and BSDs # RedHat-derivatives and BSDs
centos|fedora|redhat|scientific|freebsd|netbsd|openbsd) centos|fedora|redhat|scientific|freebsd|netbsd|openbsd)
# Hostname is FQDN # Hostname is FQDN
@ -45,14 +46,16 @@ fi
################################################################################ ################################################################################
# Check if the hostname is already correct # Check if the hostname is already correct
# #
if [ "$name_running" = "$name_should" ] && [ ! "$name_config" -o "$name_config" = "$name_should" ]; then if [ "$name_running" = "$name_should" ] \
&& [ -z "$name_config" -o "$name_config" = "$name_should" ]
then
exit 0 exit 0
fi fi
################################################################################ ################################################################################
# Setup hostname # Setup hostname
# #
echo changed >> "$__messages_out" echo 'changed' >> "$__messages_out"
# First try to set the hostname using hostnamectl, if available. # First try to set the hostname using hostnamectl, if available.
@ -69,7 +72,8 @@ EOF
fi fi
# Use the good old way to set the hostname. Also if hostnamectl fails. # Use the good old way to set the hostname. Also if hostnamectl fails.
case $os in case $os
in
archlinux|debian|ubuntu|devuan|coreos|alpine) archlinux|debian|ubuntu|devuan|coreos|alpine)
printf "printf '%%s\\\\n' '$name_should' > /etc/hostname\\n" printf "printf '%%s\\\\n' '$name_should' > /etc/hostname\\n"
echo "hostname -F /etc/hostname" echo "hostname -F /etc/hostname"

View File

@ -24,7 +24,8 @@ os=$(cat "$__global/explorer/os")
if [ -f "$__object/parameter/name" ]; then if [ -f "$__object/parameter/name" ]; then
name_should="$(cat "$__object/parameter/name")" name_should="$(cat "$__object/parameter/name")"
else else
case $os in case $os
in
# RedHat-derivatives and BSDs # RedHat-derivatives and BSDs
centos|fedora|redhat|scientific|freebsd|netbsd|openbsd) centos|fedora|redhat|scientific|freebsd|netbsd|openbsd)
# Hostname is FQDN # Hostname is FQDN
@ -44,7 +45,8 @@ not_supported() {
exit 1 exit 1
} }
case "$os" in case $os
in
archlinux|debian|suse|ubuntu|devuan|coreos|alpine|macosx) archlinux|debian|suse|ubuntu|devuan|coreos|alpine|macosx)
# handled in gencode-remote # handled in gencode-remote
: :