mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 03:12:30 +00:00 
			
		
		
		
	take out creation of /etc/resolv.conf
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10227 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -422,12 +422,6 @@ sub process_request { | ||||
|                 unlink $_; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if ($::XCATSITEVALS{useDNSonMN}) | ||||
|         { | ||||
|             create_resolvconf_on_mn($ctx); | ||||
|         } | ||||
|          | ||||
|         #We manipulate local namedconf | ||||
|         $ctx->{dbdir} = get_dbdir(); | ||||
|         $ctx->{zonesdir} = get_zonesdir(); | ||||
| @@ -1016,72 +1010,4 @@ sub makedns_usage | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| sub create_resolvconf_on_mn | ||||
| { | ||||
|     my $ctx = shift; | ||||
|      | ||||
|     my $resolvlocation = "/etc/resolv.conf"; | ||||
|     if ( -e $resolvlocation) | ||||
|     { | ||||
|        # backup the existing /etc/resolv.conf on mn if it's there | ||||
|        system("mv $resolvlocation $resolvlocation.xcatbak"); | ||||
|         | ||||
|        # put the foreign nameserver in site.forwarders | ||||
|         | ||||
|        # get forwarders which are the nameserver entries in /etc/resolv.conf | ||||
|        # don't use if the address is this machine (Management Node) | ||||
|        my $forwarders; | ||||
|        # find out the names for the Management Node | ||||
|        my @MNnodeinfo   = xCAT::Utils->determinehostname; | ||||
|        my $MNnodename   = pop @MNnodeinfo;                  # hostname | ||||
|        my @MNnodeipaddr = @MNnodeinfo;                      # ipaddresses | ||||
|  | ||||
|        my @names;  | ||||
|        my @tmpnames = | ||||
|        xCAT::Utils->runcmd("/bin/grep ^[^#]*nameserver $resolvlocation.xcatbak | awk '{print \$2}'", -1); | ||||
|        foreach my $ip (@tmpnames)  | ||||
|        { | ||||
|            if (!grep(/$ip/, @MNnodeipaddr)) | ||||
|            {     # if not the MN | ||||
|                push @names,$ip;  # add it as a forwarder | ||||
|            } | ||||
|         } | ||||
|         if (@names) | ||||
|         { | ||||
|             if ($ctx->{forwarders}) | ||||
|             { | ||||
|                 my $curforwarders = join(',', @{$ctx->{forwarders}}); | ||||
|  | ||||
|                 foreach my $name (@names) | ||||
|                 { | ||||
|                     if (!grep(/$name/, $curforwarders)) | ||||
|                     { | ||||
|                         $forwarders = $curforwarders . ",$name"; | ||||
|                         push @{$ctx->{forwarders}}, $name; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 $forwarders = join(',', @names); | ||||
|                 $ctx->{forwarders} = \@names; | ||||
|             } | ||||
|             system("$::XCATROOT/sbin/chtab key=forwarders site.value=$forwarders;"); | ||||
|         } | ||||
|     } | ||||
|     # create the new /etc/resolv.conf pointing to mn itself | ||||
|     my @newresolv; | ||||
|     push @newresolv, "search $ctx->{domain}\n"; | ||||
|     push @newresolv, "nameserver $::XCATSITEVALS{master}\n"; | ||||
|     my $newresolvconf; | ||||
|     open($newresolvconf,">",$resolvlocation); | ||||
|     flock($newresolvconf,LOCK_EX); | ||||
|     seek($newresolvconf,0,0); | ||||
|     truncate($newresolvconf,0); | ||||
|     for my $l  (@newresolv) { print $newresolvconf $l; } | ||||
|     flock($newresolvconf,LOCK_UN); | ||||
|     close($newresolvconf); | ||||
|     return; | ||||
| } | ||||
|  | ||||
| 1; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user