[__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/>. # 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") os=$(cat "$__global/explorer/os")
name_running=$(cat "$__global/explorer/hostname") name_running=$(cat "$__global/explorer/hostname")
name_config=$(cat "$__object/explorer/persistent_hostname") name_config=$(cat "$__object/explorer/persistent_hostname")
has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl") 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 # Check if the hostname is already correct
# #

View file

@ -24,16 +24,16 @@ 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
name_should="${__target_host}" name_should="${__target_host}"
;; ;;
*) *)
# Hostname is only first component of FQDN # Hostname is only first component of FQDN
name_should="${__target_host%%.*}" name_should="${__target_host%%.*}"
;; ;;
esac esac
fi fi