2008-02-25 13:05:21 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#-------------------------------------------------------
|
|
|
|
package xCAT_plugin::DNSsn;
|
|
|
|
use xCAT::Table;
|
|
|
|
|
|
|
|
use xCAT::Utils;
|
|
|
|
|
|
|
|
use xCAT::MsgUtils;
|
|
|
|
use Getopt::Long;
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2008-05-22 18:21:01 +00:00
|
|
|
=head1
|
|
|
|
xCAT plugin package to setup of DNS
|
2008-02-25 13:05:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2008-05-22 18:21:01 +00:00
|
|
|
=head3 handled_commands
|
2008-02-25 13:05:21 +00:00
|
|
|
|
|
|
|
Check to see if on a Service Node
|
|
|
|
Check database to see if this node is a DNS server
|
|
|
|
Call setup_DNS
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
sub handled_commands
|
|
|
|
{
|
2008-05-19 18:15:48 +00:00
|
|
|
# If called in XCATBYPASS mode, don't do any setup
|
|
|
|
if ($ENV{'XCATBYPASS'}) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-26 13:50:39 +00:00
|
|
|
my $rc = 0;
|
2008-02-25 13:05:21 +00:00
|
|
|
if (xCAT::Utils->isServiceNode())
|
|
|
|
{
|
|
|
|
my @nodeinfo = xCAT::Utils->determinehostname;
|
2008-03-16 13:40:12 +00:00
|
|
|
my $nodename = pop @nodeinfo; # get hostname
|
|
|
|
my @nodeipaddr = @nodeinfo; # get ip addresses
|
2008-05-06 15:42:57 +00:00
|
|
|
my $service = "nameserver";
|
2008-02-25 13:05:21 +00:00
|
|
|
|
2008-03-06 18:42:32 +00:00
|
|
|
$rc = xCAT::Utils->isServiceReq($nodename, $service, \@nodeipaddr);
|
2008-02-25 13:05:21 +00:00
|
|
|
if ($rc == 1)
|
|
|
|
{
|
|
|
|
|
|
|
|
# service needed on this Service Node
|
2008-03-18 18:11:42 +00:00
|
|
|
$rc = &setup_DNS(); # setup DNS
|
2008-02-26 13:50:39 +00:00
|
|
|
if ($rc == 0)
|
|
|
|
{
|
|
|
|
xCAT::Utils->update_xCATSN($service);
|
|
|
|
}
|
2008-02-25 13:05:21 +00:00
|
|
|
}
|
2008-03-16 13:40:12 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ($rc == 2)
|
|
|
|
{ # service setup, just start the daemon
|
|
|
|
$cmd = "service named start";
|
2008-05-13 15:11:50 +00:00
|
|
|
system $cmd;
|
|
|
|
if ($? > 0)
|
|
|
|
{ # error
|
|
|
|
xCAT::MsgUtils->message("S", "Error on command: $cmd");
|
|
|
|
return 1;
|
|
|
|
}
|
2008-05-22 18:21:01 +00:00
|
|
|
|
2008-03-16 13:40:12 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-25 13:05:21 +00:00
|
|
|
}
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2008-05-22 18:21:01 +00:00
|
|
|
=head3 process_request
|
2008-02-25 13:05:21 +00:00
|
|
|
|
|
|
|
Process the command
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub process_request
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
2008-05-22 18:21:01 +00:00
|
|
|
=head3 setup_DNS
|
2008-02-25 13:05:21 +00:00
|
|
|
|
2008-05-22 18:21:01 +00:00
|
|
|
Sets up Domain Name service
|
2008-02-25 13:05:21 +00:00
|
|
|
http://www.adminschoice.com/docs/domain_name_service.htm#Introduction
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub setup_DNS
|
|
|
|
{
|
2008-05-07 17:20:34 +00:00
|
|
|
# setup the named.conf file
|
2008-05-22 18:21:01 +00:00
|
|
|
system("/opt/xcat/sbin/makenamed.conf");
|
2008-03-18 18:11:42 +00:00
|
|
|
# turn DNS on
|
|
|
|
|
|
|
|
$cmd = "chkconfig named on";
|
2008-05-13 15:11:50 +00:00
|
|
|
system $cmd;
|
|
|
|
if ($? > 0)
|
2008-02-25 13:05:21 +00:00
|
|
|
{
|
2008-03-18 18:11:42 +00:00
|
|
|
xCAT::MsgUtils->message("S", "Error from $cmd");
|
|
|
|
return 1;
|
2008-02-25 13:05:21 +00:00
|
|
|
}
|
2008-05-13 15:11:50 +00:00
|
|
|
$cmd = "service named restart";
|
|
|
|
system $cmd;
|
|
|
|
if ($? > 0)
|
2008-03-18 18:11:42 +00:00
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message("S", "Error from $cmd");
|
2008-02-25 13:05:21 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2008-03-18 18:11:42 +00:00
|
|
|
|
2008-05-13 15:11:50 +00:00
|
|
|
|
2008-02-25 13:05:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
1;
|