diff --git a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node index e516a138a..e67f48393 100755 --- a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node +++ b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node @@ -100,8 +100,8 @@ change_host_name() if [ "$str_os_type" = "sles" ];then echo "Persistently changing the hostname not implemented yet." - #debian ubuntu - elif [ "$str_os_type" = "debian" ];then + #debian ubuntu and rh7 + elif [ -f "/etc/hostname" ];then conf_file="/etc/hostname" echo "$str_hostname" > $conf_file else diff --git a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node index da148f47e..81ef22564 100755 --- a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node +++ b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node @@ -36,8 +36,8 @@ change_host_name() if [ "$str_os_type" = "sles" ];then echo "Persistently changing the hostname not implemented yet." - #debian ubuntu - elif [ "$str_os_type" = "debian" ];then + #debian ubuntu and rh7 + elif [ -f "/etc/hostname" ];then conf_file="/etc/hostname" echo "$str_hostname" > $conf_file else diff --git a/xCAT-server/share/xcat/hamn/deactivate-mn b/xCAT-server/share/xcat/hamn/deactivate-mn index da2f19dd2..9a4ab6ddf 100755 --- a/xCAT-server/share/xcat/hamn/deactivate-mn +++ b/xCAT-server/share/xcat/hamn/deactivate-mn @@ -251,7 +251,11 @@ then then BOOT_HOSTNAME=$(lsattr -El inet0 -a hostname | awk '{print $2}') else # Linux - BOOT_HOSTNAME=`grep HOSTNAME /etc/sysconfig/network | cut -f 2 -d "="` + if [ -f "/etc/hostname" ]; then + BOOT_HOSTNAME=`cat /etc/hostname` + else + BOOT_HOSTNAME=`grep HOSTNAME /etc/sysconfig/network | cut -f 2 -d "="` + fi fi hostname ${BOOT_HOSTNAME} fi diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index 5bc33da04..195fab5a6 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -393,11 +393,15 @@ elif [ "$1" = "-s" ];then fi fi hostname $NODE - grep -i "HOSTNAME" /etc/sysconfig/network - if [ $? -eq 0 ];then - sed -i "s/.*HOSTNAME.*/HOSTNAME=${NODE}/i" /etc/sysconfig/network + if [ -f "/etc/hostname" ]; then + echo $NODE > /etc/hostname else - echo "HOSTNAME=${NODE}" >> /etc/sysconfig/network + grep -i "HOSTNAME" /etc/sysconfig/network + if [ $? -eq 0 ];then + sed -i "s/.*HOSTNAME.*/HOSTNAME=${NODE}/i" /etc/sysconfig/network + else + echo "HOSTNAME=${NODE}" >> /etc/sysconfig/network + fi fi fi exit 0 diff --git a/xCAT/postscripts/hardeths b/xCAT/postscripts/hardeths index b29e2953c..f3f8b2236 100755 --- a/xCAT/postscripts/hardeths +++ b/xCAT/postscripts/hardeths @@ -63,7 +63,11 @@ then else #RedHat uses /etc/sysconfig/network-scripts/ifcfg-eth NICFILEPRE="/etc/sysconfig/network-scripts/ifcfg-" - sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network + if [ -f "/etc/hostname" ]; then # for rh7 + echo `hostname` >/etc/hostname + else + sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network + fi if [ ! -z "$defgw" ]; then echo "GATEWAY=$defgw" >> /etc/sysconfig/network fi diff --git a/xCAT/postscripts/updatenetwork b/xCAT/postscripts/updatenetwork index d1bcd6a4c..8da573914 100644 --- a/xCAT/postscripts/updatenetwork +++ b/xCAT/postscripts/updatenetwork @@ -16,11 +16,15 @@ device_names=`ip link |grep "BROADCAST" |awk '{print $2}' | sed s/://` str_cfg_file='' if [ -d "/etc/sysconfig/network-scripts/" ];then #redhat - grep -i HOSTNAME /etc/sysconfig/network - if [ $? -eq 0 ];then - sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network + if [ -f "/etc/hostname" ]; then #RH7 + echo $HOSTNAME > /etc/hostname else - echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network + grep -i HOSTNAME /etc/sysconfig/network + if [ $? -eq 0 ];then + sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network + else + echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network + fi fi for i in $device_names;do str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$i"