mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-06-13 01:40:26 +00:00
-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
This commit is contained in:
@ -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>) {
|
||||
|
Reference in New Issue
Block a user