From 89b77265644c1c43bd404fa8f097feee9ccacafc Mon Sep 17 00:00:00 2001 From: daniceexi Date: Mon, 19 Apr 2010 12:20:47 +0000 Subject: [PATCH] add the localhost entry automatically when running the makehosts -n git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5810 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/hosts.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index 05f7f7ada..5e6e2fd4f 100644 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -173,6 +173,13 @@ sub process_request { if (-e "/etc/hosts") { my $bakname = "/etc/hosts.xcatbak"; rename("/etc/hosts",$bakname); + + # add the localhost entry if trying to create the /etc/hosts from scratch + if ($^O =~ /^aix/i) { + push @hosts, "127.0.0.1 loopback localhost\n"; + } else { + push @hosts, "127.0.0.1 localhost\n"; + } } } else { if (-e "/etc/hosts") { @@ -217,7 +224,10 @@ sub process_request { } } writeout(); - flock($lockh,LOCK_UN); + + if ($lockh) { + flock($lockh,LOCK_UN); + } }