From 3fc059acb47833b770ad930e91e496e8a0aa5ec5 Mon Sep 17 00:00:00 2001 From: otubo Date: Mon, 15 Aug 2011 00:30:40 +0000 Subject: [PATCH] Fix for bug #3391658, by Renan Guerra git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10286 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 13 +++++++++++++ xCAT-server/lib/xcat/plugins/AAsn.pm | 18 +++++++++++++++--- xCAT-server/lib/xcat/plugins/ddns.pm | 26 ++++++++++++++++++++------ xCAT-server/sbin/makenamed.conf | 5 +++++ 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 9e96227d5..7d7e08196 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -4909,6 +4909,19 @@ sub osver $ver =~ tr/\.//; $ver =~ s/[^0-9]*([0-9]+).*/$1/; } + elsif (-f "/etc/lsb-release")#ubuntu + { + + $os = "ubuntu"; + open($relfile,"<","/etc/lsb-release"); + my @text = <$relfile>; + close($relfile); + foreach (@text){ + if ( $_ =~ /DISTRIB_RELEASE=(\S+)/ ) { + $ver = $1; + } + } + } $os = "$os" . "$ver"; return ($os); } diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index c2bc67197..fc7fa7df9 100644 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -643,7 +643,13 @@ sub setup_DHCP ${"xCAT_plugin::" . $modname . "::"}{process_request} ->($cmdref, \&xCAT::Client::handle_response); - my $rc = xCAT::Utils->startService("dhcpd"); + + my $distro = xCAT::Utils->osver(); + my $serv = "dhcpd"; + if ( $distro =~ /ubuntu*/ ){ + $serv = "dhcp3-server"; + } + my $rc = xCAT::Utils->startService($serv); if ($rc != 0) { return 1; @@ -732,8 +738,14 @@ sub setup_DNS system("$XCATROOT/sbin/makenamed.conf"); # turn DNS on - - my $rc = xCAT::Utils->startService("named"); + + my $distro = xCAT::Utils->osver(); + my $serv = "named"; + if ( $distro =~ /ubuntu*/ ){ + $serv = "bind9"; + } + + my $rc = xCAT::Utils->startService($serv); if ($rc != 0) { return 1; diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 6d1969065..b1f217189 100644 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -14,9 +14,15 @@ use Fcntl qw/:flock/; #This is a rewrite of DNS management using nsupdate rather than direct zone mangling my $callback; -my $service="named"; +my $distro = xCAT::Utils->osver(); +my $service="named"; +# is this ubuntu ? +if ( $distro =~ /ubuntu*/ ){ + $service = "bind9"; +} + sub handled_commands { return {"makedns" => "site:dnshandler"}; @@ -461,7 +467,7 @@ sub process_request { } else { - system("/sbin/service $service stop"); #named may otherwise hold on to stale journal filehandles + system("service $service stop"); #named may otherwise hold on to stale journal filehandles } my $conf = get_conf(); unlink $conf; @@ -486,8 +492,8 @@ sub process_request { } else { - system("/sbin/service $service stop"); - system("/sbin/service $service start"); + system("service $service stop"); + system("service $service start"); } xCAT::SvrUtils::sendmsg("Restarting named complete", $callback); } @@ -526,7 +532,11 @@ sub get_zonesdir { sub get_conf { my $conf="/etc/named.conf"; - + # is this ubuntu ? + if ( $distro =~ /ubuntu*/ ){ + $conf="/etc/bind/named.conf"; + } + my $sitetab = xCAT::Table->new('site'); unless ($sitetab) @@ -571,7 +581,11 @@ sub get_dbdir { # Temp fix for bugzilla 73119 chown(scalar(getpwnam('root')),scalar(getgrnam('named')),"/var/lib/named"); return "/var/lib/named/"; - } else { + } + elsif (-d "/var/lib/bind") { + return "/var/lib/bind/"; + } + else { mkpath "/var/named/"; chown(scalar(getpwnam('named')),scalar(getgrnam('named')),"/var/named"); return "/var/named/"; diff --git a/xCAT-server/sbin/makenamed.conf b/xCAT-server/sbin/makenamed.conf index 928b76054..bbfb7b38a 100755 --- a/xCAT-server/sbin/makenamed.conf +++ b/xCAT-server/sbin/makenamed.conf @@ -7,6 +7,11 @@ if [ -f /etc/SuSE-release ]; then DIRECTORY=/var/lib/named fi FILE=/etc/named.conf + +if [ -f /etc/lsb-release ]; then + FILE=/etc/bind/named.conf +fi + #unalias cp if [ -f $FILE ]; then cp -f $FILE ${FILE}.ORIG