From e3ec966e33ab3f6429eec714e1b01af3994cef2b Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Tue, 3 Jun 2008 20:28:01 +0000 Subject: [PATCH] -Backup hosts file before makehosts git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1575 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/hosts.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index eaab7a6e5..acddc90c7 100644 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -46,12 +46,13 @@ sub process_request { if (grep /-n/,@{$req->{arg}}) { if (-e "/etc/hosts") { my $bakname = "/etc/hosts.xcatbak"; - while (-e $bakname) { #look for unused backup name.. - $bakname .= "~"; - } rename("/etc/hosts",$bakname); } } else { + if (-e "/etc/hosts") { + my $bakname = "/etc/hosts.xcatbak"; + copy("/etc/hosts",$bakname); + } open($rconf,"/etc/hosts"); # Read file into memory if ($rconf) { while (<$rconf>) {