From 0ae7e5d83d631a5ba035501d013ca9ce6d75040d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Rodr=C3=ADguez?= Date: Wed, 18 May 2016 14:39:50 +0200 Subject: [PATCH] Modifying file /etc/hostname to set the hostname On RHEL and CentOS 7 host name is kept in /etc/hostname, so even if SET_HOSTNAME has a value, the machine was keeping localhost.localdomain as name. This way the hostname file gets overwritten with contextualization variable value. I'm supposing that file /etc/hostname will be existing in next releases too (OS_VERSION >= 7) --- base_rpm.one/etc/one-context.d/15-hostname | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/base_rpm.one/etc/one-context.d/15-hostname b/base_rpm.one/etc/one-context.d/15-hostname index df77aa0..37eeace 100755 --- a/base_rpm.one/etc/one-context.d/15-hostname +++ b/base_rpm.one/etc/one-context.d/15-hostname @@ -9,7 +9,8 @@ function set_hostname() { sed -i '/^HOSTNAME=.*$/d' $CONFIG_FILE echo "HOSTNAME=$NAME" >> $CONFIG_FILE - + [[ $(awk -F= '/^VERSION_ID/ {gsub("\"","");print $2}' /etc/os-release) -ge 7 ]] && echo $NAME > /etc/hostname + hostname $NAME }