[__hostname] Copy FQDN-logic to gencode-remote

Otherwise, the code-remote gets run on the remote every time.
This commit is contained in:
Dennis Camera 2019-10-06 18:23:56 +02:00
parent 3e7cf68de5
commit cbb108d61c
2 changed files with 27 additions and 16 deletions

View File

@ -20,17 +20,28 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
if [ -f "$__object/parameter/name" ]; then
name_should="$(cat "$__object/parameter/name")"
else
name_should="${__target_host%%.*}"
fi
os=$(cat "$__global/explorer/os")
name_running=$(cat "$__global/explorer/hostname")
name_config=$(cat "$__object/explorer/persistent_hostname")
has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl")
if [ -f "$__object/parameter/name" ]; then
name_should="$(cat "$__object/parameter/name")"
else
case $os in
# RedHat-derivatives and BSDs
centos|fedora|redhat|scientific|freebsd|netbsd|openbsd)
# Hostname is FQDN
name_should="${__target_host}"
;;
*)
# Hostname is only first component of FQDN
name_should="${__target_host%%.*}"
;;
esac
fi
################################################################################
# Check if the hostname is already correct
#

View File

@ -24,16 +24,16 @@ os=$(cat "$__global/explorer/os")
if [ -f "$__object/parameter/name" ]; then
name_should="$(cat "$__object/parameter/name")"
else
case "$os" in
# RedHat-derivatives and BSDs
centos|fedora|redhat|scientific|freebsd|netbsd|openbsd)
# Hostname is FQDN
name_should="${__target_host}"
;;
*)
# Hostname is only first component of FQDN
name_should="${__target_host%%.*}"
;;
case $os in
# RedHat-derivatives and BSDs
centos|fedora|redhat|scientific|freebsd|netbsd|openbsd)
# Hostname is FQDN
name_should="${__target_host}"
;;
*)
# Hostname is only first component of FQDN
name_should="${__target_host%%.*}"
;;
esac
fi