diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 5156d75a1..20ace79e8 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -44,6 +44,17 @@ $::INSTALLDIR = "/install"; # Default TFTP dir location $::TFTPDIR = "/tftpboot"; + my $arraysize=@ARGV; + if ($arraysize ==0) { + my $msg= "No parameters were supplied on the xcatconfig command. Run xcatconfig -h" ; + xCAT::MsgUtils->message("E", $msg); + exit 1; + } + +Getopt::Long::Configure("posix_default"); +Getopt::Long::Configure("no_gnu_compat"); +Getopt::Long::Configure("bundling"); + # parse the options if ( !GetOptions( @@ -67,20 +78,6 @@ if ( exit(1); } -if ( (!$::HELP) - && (!$::FORCE) - && (!$::INITIALINSTALL) - && (!$::UPDATEINSTALL) - && (!$::genSSHRootKeys) - && (!$::genSSHNodeHostKeys) - && (!$::genCredentials) - && (!$::setupMNinDB) - && (!$::initDB) - && (!$::VERSION)) -{ - &usage; - exit(1); -} # display the usage if -h or --help is specified if ($::HELP) @@ -2063,7 +2060,8 @@ sub cleanupPSTable =head3 setupMNinDB - Will add/replace the management node to the database with group=__mgmtnode + Will add/replace the management node to the noderes table with group=__mgmtnode + Will add/replace the management node to the servicenode tble with group=__mgmtnode =cut @@ -2075,15 +2073,17 @@ sub setupMNinDB chomp $mnname; $mnname && $mnname =~ s/\..*//; # strip off domain - # check to see if MN already defined in the database - my $cmds ="XCATBYPASS=Y $::XCATROOT/sbin/tabdump nodelist | grep __mgmtnode"; + # check to see if MN already defined in the nodelist + + my $defined = 0; + my $cmds="XCATBYPASS=Y $::XCATROOT/sbin/tabdump nodelist | grep __mgmtnode"; my $output = xCAT::Utils->runcmd("$cmds", -1); if ($::RUNCMD_RC == 0) # found a management node defined { my $chtabcmds; my @mn = split(",", $output); $mn[0] =~ s/"//g; # remove the quotes - if ($mn[0] ne $mnname) { # remove the old, if not current + if ($mn[0] ne $mnname) { # does not match current host name,delete it $chtabcmds = "$::XCATROOT/sbin/chtab -d node=$mn[0] nodelist;"; my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); if ($::RUNCMD_RC != 0) @@ -2091,23 +2091,67 @@ sub setupMNinDB xCAT::MsgUtils->message('E', "Could not run $chtabcmds."); return; } - - } else { # already defined correctly - return; + } else { # it is defined and good + xCAT::MsgUtils->message('I', "$mnname already defined in the nodelist table."); + $defined=1; } + } + # now add with the new name , if not already there + if ($defined ==0) { + my $chtabcmds = "$::XCATROOT/sbin/chtab node=$mnname nodelist.groups=__mgmtnode;"; + my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message('E', "Could not add $mnname to the noderes table."); + } + else + { + verbose("Added $mnname to the noderes table."); + } + } - # now add a new one - my $chtabcmds = "$::XCATROOT/sbin/chtab node=$mnname nodelist.groups=__mgmtnode;"; - my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); - if ($::RUNCMD_RC != 0) + # now add to the servicenode table with default settings + # check to see if MN already defined in the servicenode table + my $cmds="XCATBYPASS=Y $::XCATROOT/sbin/tabdump servicenode | grep __mgmtnode"; + my $output = xCAT::Utils->runcmd("$cmds", -1); + if ($::RUNCMD_RC != 0) # no management node defined { - xCAT::MsgUtils->message('E', "Could not add $mnname to the database."); + # add to the servicenode table + my $chtabcmds; + if (xCAT::Utils->isLinux()) { + # always setup tftp + $chtabcmds= + "$::XCATROOT/sbin/chtab node=__mgmtnode servicenode.tftpserver=yes "; + # check setting of site.vsftp to see if we want to setup ftp + $cmds="XCATBYPASS=Y $::XCATROOT/sbin/tabdump site | grep vsftp"; + $output = xCAT::Utils->runcmd("$cmds", -1); + if ($::RUNCMD_RC == 0){ # vsftp defined + # check the setting to see if we want ftp + my @vals = split(',', $output); + if ($vals[1] && ($vals[1] !~ /0|NO|No|no|N|n/ )) { # setup ftp + $chtabcmds .= " servicenode.ftpserver=yes "; + } + } + } else { # AIX, don't define any services just add the MN node + $chtabcmds = + "$::XCATROOT/sbin/chtab node=__mgmtnode servicenode.ftpserver=no;"; + } + + my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message('E', "Could not add $mnname to the servicenode table."); + } + else + { + verbose("Added $mnname to the servicenode table table."); + } + + } else { # it was already defined in the servicenode table + xCAT::MsgUtils->message('I', "$mnname was already defined in the servicenode table."); + } - else - { - verbose("Added $mnname to the database."); - } - return; + return; } #-----------------------------------------------------------------------------