2008-01-22 18:53:53 +00:00
#!/usr/bin/perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#
#####################################################
#
# This is script is called during the initial installation of xCAT
# It can also be called directly to redo the xcat configuration
#
#####################################################
BEGIN
{
2008-06-11 18:45:47 +00:00
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
$::XCATDIR = $ENV{'XCATDIR'} ? $ENV{'XCATDIR'} : '/etc/xcat';
2008-01-22 18:53:53 +00:00
}
use lib "$::XCATROOT/lib/perl";
use xCAT::Utils;
use Getopt::Long;
use xCAT::MsgUtils;
use Socket;
$::progname = "xcatconfig";
2008-06-11 18:45:47 +00:00
Getopt::Long::Configure("bundling");
$Getopt::Long::ignorecase = 0;
2008-01-22 18:53:53 +00:00
# parse the options
2008-06-11 18:45:47 +00:00
if (
!GetOptions(
'f|force' => \$::FORCE,
'h|help' => \$::HELP,
'v|version' => \$::VERSION,
)
)
2008-01-22 18:53:53 +00:00
{
2008-06-11 18:45:47 +00:00
&usage;
exit(1);
2008-01-22 18:53:53 +00:00
}
# display the usage if -h or --help is specified
2008-06-11 18:45:47 +00:00
if ($::HELP)
{
&usage;
exit(0);
2008-01-22 18:53:53 +00:00
}
# display the version statement if -v or --verison is specified
if ($::VERSION)
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('I', "$::progname: version 1.0\n");
exit(0);
2008-01-22 18:53:53 +00:00
}
2008-06-11 18:45:47 +00:00
$::osname = `uname`;
2008-01-22 18:53:53 +00:00
chomp $::osname;
2008-06-11 18:45:47 +00:00
if ($::osname eq 'AIX')
{
$::arch = `uname -p`;
$::root = "";
}
else
{
$::arch = `uname -m`;
$::root = "/root";
2008-01-22 18:53:53 +00:00
}
chomp $::arch;
chomp $::root;
2009-02-10 19:48:29 +00:00
2008-11-03 16:52:30 +00:00
# Make this system a management node
my $cmd = "/bin/touch /etc/xCATMN";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "Could not create /etc/xCATMN file.\n");
}
else
{
xCAT::MsgUtils->message('I', "Created /etc/xCATMN file.\n");
}
2009-02-10 19:48:29 +00:00
# Make sure service node file is not there
if (-f "/etc/xCATSN")
{
my $cmd = "/bin/rm /etc/xCATSN";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-12-11 18:22:23 +00:00
}
2008-06-11 18:45:47 +00:00
2008-05-29 13:50:12 +00:00
# some Linux-only config
# (used to FTP postscripts to nodes)
2008-06-11 18:45:47 +00:00
if ($::osname eq 'Linux')
{
2008-05-29 13:50:12 +00:00
# Locally mount /var/ftp/install over /install
2008-06-11 18:45:47 +00:00
if (!-d "/var/ftp/install")
{
my $cmd = "/bin/mkdir -p /var/ftp/install";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not create /var/ftp/install directory.\n");
}
else
{
xCAT::MsgUtils->message('I',
"Created /var/ftp/install directory.\n");
}
}
#
# add /var/ftp/install to /etc/fstab and mount - if needed
#
my $changed_fstab = 0;
my $cmd = "/bin/cat /etc/fstab | grep '/var/ftp/install'";
my $outref = xCAT::Utils->runcmd("$cmd", -1);
if ($::RUNCMD_RC != 0)
{
# ok - then add this entry
my $cmd =
"/bin/echo '/install /var/ftp/install none bind,defaults 0 0' >> /etc/fstab";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not update the /etc/fstab file.\n");
}
else
{
xCAT::MsgUtils->message('I',
"Added /var/ftp/install to the /etc/fstab file.\n");
$changed_fstab++;
}
}
if ($changed_fstab)
{
# mount /var/ftp/install
my $cmd = "mount /var/ftp/install";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "Could not mount /var/ftp/install.\n");
}
else
{
xCAT::MsgUtils->message('I',
"/var/ftp/install has been mounted over /install.\n");
}
}
#
# add /var/ftp/tftpboot to /etc/fstab and mount - if needed
#
my $changed_fstab = 0;
my $cmd = "/bin/cat /etc/fstab | grep '/var/ftp/tftpboot'";
my $outref = xCAT::Utils->runcmd("$cmd", -1);
if ($::RUNCMD_RC != 0)
{
# ok - then add this entry
my $cmd =
"/bin/echo '/tftpboot /var/ftp/tftpboot none bind,defaults 0 0' >> /etc/fstab";
2008-05-29 13:50:12 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not update the /etc/fstab file.\n");
}
else
{
xCAT::MsgUtils->message('I',
"Added /var/ftp/tftpboot to the /etc/fstab file.\n");
$changed_fstab++;
}
}
if ($changed_fstab)
{
# mount /var/ftp/tftpboot
my $cmd = "mount /var/ftp/tftpboot";
2008-05-29 13:50:12 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not mount /var/ftp/tftpboot.\n");
}
else
{
xCAT::MsgUtils->message('I',
"/var/ftp/tftpboot has been mounted over /tftpboot.\n");
}
}
# start vsftpd
my $cmd = "/sbin/chkconfig vsftpd on";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-10-17 17:59:57 +00:00
my $cmd = "/etc/init.d/vsftpd restart";
2008-06-11 18:45:47 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "Could not start VSFTPD.\n");
}
else
{
2008-05-29 13:50:12 +00:00
xCAT::MsgUtils->message('I', "VSFTPD has been restarted.\n");
2008-06-11 18:45:47 +00:00
}
2008-05-29 13:50:12 +00:00
2008-06-11 18:45:47 +00:00
} # - some Linux-only config
2008-01-22 18:53:53 +00:00
#
2008-06-11 18:45:47 +00:00
# Generate ssh keys
2008-01-22 18:53:53 +00:00
#
2008-06-11 18:45:47 +00:00
2009-02-10 19:48:29 +00:00
# create /etc/xcat/hostkeys and /install/postscripts/hostkeys
if (!-d "/install/postscripts/hostkeys") # directory for public keys
{
my $cmd = "/bin/mkdir -p /install/postscripts/hostkeys";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
2008-06-11 18:45:47 +00:00
{
2009-02-10 19:48:29 +00:00
xCAT::MsgUtils->message('E',
2008-06-11 18:45:47 +00:00
"Could not create /install/postscripts/hostkeys directory.\n");
}
2009-02-10 19:48:29 +00:00
}
if (!-d "/etc/xcat/hostkeys") # directory for public/private keys
{
my $cmd = "/bin/mkdir -p /etc/xcat/hostkeys";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not create /etc/xcat/hostkeys directory.\n");
}
}
2008-06-11 18:45:47 +00:00
2009-02-10 19:48:29 +00:00
if ($::FORCE)
{
# remove the old keys
my $cmd = "/bin/rm /install/postscripts/hostkeys/ssh_host*";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
2008-06-11 18:45:47 +00:00
{
2009-02-10 19:48:29 +00:00
xCAT::MsgUtils->message(
'I',
"Could not remove ssh keys from /install/postscripts/hostkeys directory. They may not exist.\n"
);
}
2008-06-11 18:45:47 +00:00
2009-02-10 19:48:29 +00:00
# remove the old keys
my $cmd = "/bin/rm /etc/xcat/hostkeys/ssh_host*";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message(
'I',
"Could not remove ssh keys from /etc/xcat/hostkeys directory. They may not exist.\n"
);
2008-06-11 18:45:47 +00:00
}
2009-02-10 19:48:29 +00:00
#
# generate new hostkeys
#
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('I', "Generating SSH1 RSA Key...\n");
my $cmd =
2009-02-10 19:48:29 +00:00
"/usr/bin/ssh-keygen -t rsa1 -f /etc/xcat/hostkeys/ssh_host_key -C '' -N ''";
2008-06-11 18:45:47 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "Could not generate SSH1 RSA key.\n");
}
xCAT::MsgUtils->message('I', "Generating SSH2 RSA Key...\n");
my $cmd =
2009-02-10 19:48:29 +00:00
"/usr/bin/ssh-keygen -t rsa -f /etc/xcat/hostkeys/ssh_host_rsa_key -C '' -N ''";
2008-06-11 18:45:47 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "Could not generate SSH2 RSA key.\n");
}
xCAT::MsgUtils->message('I', "Generating SSH2 DSA Key...\n");
my $cmd =
2009-02-10 19:48:29 +00:00
"/usr/bin/ssh-keygen -t dsa -f /etc/xcat/hostkeys/ssh_host_dsa_key -C '' -N ''";
2008-06-11 18:45:47 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
2008-01-22 18:53:53 +00:00
{
xCAT::MsgUtils->message('E', "Could not generate SSH2 DSA key.\n");
}
2009-02-10 19:48:29 +00:00
# copy the public keys to install directory
my $cmd =
"/bin/cp /etc/xcat/hostkeys/*.pub /install/postscripts/hostkeys/.";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "$cmd not successful.\n");
}
else
{
xCAT::MsgUtils->message('I', "$cmd is successful\n");
}
2008-06-11 18:45:47 +00:00
}
2009-02-10 19:48:29 +00:00
#
# move old keys if they exist, to the new directory and remove private keys
if (-f "/install/postscripts/hostkeys/ssh_host_key")
2008-06-11 18:45:47 +00:00
{
2009-02-10 19:48:29 +00:00
# copy all keys to /etc/xcat/hostkeys directory
my $cmd = "/bin/cp -p /install/postscripts/hostkeys/* /etc/xcat/hostkeys/.";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "$cmd not successful.\n");
}
# remove private keys from install dir
if (-f "/install/postscripts/hostkeys/ssh_host_dsa_key")
{
my $cmd = "/bin/rm /install/postscripts/hostkeys/ssh_host_dsa_key";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "$cmd not successful.\n");
}
}
if (-f "/install/postscripts/hostkeys/ssh_host_key")
{
my $cmd = "/bin/rm /install/postscripts/hostkeys/ssh_host_key";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "$cmd not successful.\n");
}
}
if (-f "/install/postscripts/hostkeys/ssh_host_rsa_key")
{
my $cmd = "/bin/rm /install/postscripts/hostkeys/ssh_host_rsa_key";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "$cmd not successful.\n");
}
}
2008-01-22 18:53:53 +00:00
}
#
2008-05-29 13:50:12 +00:00
# move old directories if they exist
2008-06-11 18:45:47 +00:00
if (-d "/install/postscripts/.ssh")
{
2009-02-10 19:48:29 +00:00
my $cmd = "/bin/mv /install/postscripts/.ssh/* /install/postscripts/_ssh/.";
2008-10-31 16:21:01 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", -1);
2009-02-10 19:48:29 +00:00
my $cmd = "/bin/rmdir /install/postscripts/.ssh";
my $outref = xCAT::Utils->runcmd("$cmd", -1);
# if ($::RUNCMD_RC != 0)
# {
2008-10-31 16:21:01 +00:00
# xCAT::MsgUtils->message(
2009-02-10 19:48:29 +00:00
# 'E',
# "Could not move /install/postscripts/.ssh directory to /install/postscripts/_ssh.\n"
# );
# }
# else
# {
2008-10-31 16:21:01 +00:00
# xCAT::MsgUtils->message(
# 'I',
2009-02-10 19:48:29 +00:00
# "Moved /install/postscripts/.ssh directory to /install/postscripts/_ssh.\n"
2008-10-31 16:21:01 +00:00
# );
2009-02-10 19:48:29 +00:00
# }
2008-06-11 18:45:47 +00:00
}
if (-d "/install/postscripts/.xcat")
{
2009-02-10 19:48:29 +00:00
my $cmd = "/bin/mv /install/postscripts/.xcat/* /install/postscripts/_xcat/.";
2008-06-11 18:45:47 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message(
'E',
"Could not move /install/postscripts/.xcat directory to /install/postscripts/_xcat.\n"
);
}
2009-02-10 19:48:29 +00:00
my $cmd = "/bin/rmdir /install/postscripts/.xcat";
my $outref = xCAT::Utils->runcmd("$cmd", -1);
2008-05-29 13:50:12 +00:00
}
#
2008-06-11 18:45:47 +00:00
# create /.ssh dir if needed
2008-01-22 18:53:53 +00:00
#
my $sshdir = "$::root/.ssh";
2008-06-11 18:45:47 +00:00
if (!-d $sshdir)
{
my $cmd = "/bin/mkdir -m 700 -p $sshdir";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "Could not create $sshdir directory.\n");
}
else
{
xCAT::MsgUtils->message('I', "Created $sshdir directory.\n");
}
2008-01-22 18:53:53 +00:00
}
#
# create or modify the -/.ssh/config file
#
my $cfgfile = "$::root/.ssh/config";
2008-06-11 18:45:47 +00:00
if ((-f $cfgfile) || $::FORCE)
{
# it exists - so see if it needs to be updated - ???????? check!!!
# xCAT::MsgUtils->message('I', "Checking for \'StrictHostKeyChecking no\' in $cfgfile.\n");
my $cmd = "/bin/cat $cfgfile | grep 'StrictHostKeyChecking no'";
my $outref = xCAT::Utils->runcmd("$cmd", -1);
if ($::RUNCMD_RC != 0)
{
# ok - then add this entry
my $cmd =
"/bin/echo StrictHostKeyChecking no >> $cfgfile; chmod 600 $cfgfile";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not update the $cfgfile file.\n");
}
else
{
xCAT::MsgUtils->message('I',
"Added updates to the $cfgfile file.\n");
}
}
}
else
{
# file doesn't exist so just create it
my $cmd =
"/bin/echo StrictHostKeyChecking no > $cfgfile; chmod 600 $cfgfile";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "Could not update the $cfgfile file.\n");
}
else
{
xCAT::MsgUtils->message('I', "Added updates to the $cfgfile file.\n");
}
2008-01-22 18:53:53 +00:00
}
#
2008-06-11 18:45:47 +00:00
# create /install/postscripts/_ssh if needed
2008-01-22 18:53:53 +00:00
#
2008-06-11 18:45:47 +00:00
if (!-d "/install/postscripts/_ssh")
{
2008-05-29 13:50:12 +00:00
my $cmd = "/bin/mkdir -p /install/postscripts/_ssh";
2008-01-22 18:53:53 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
2008-01-22 18:53:53 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('E',
"Could not create /install/postscripts/_ssh directory.\n");
}
else
{
xCAT::MsgUtils->message('I',
"Created /install/postscripts/_ssh directory.\n");
2008-01-22 18:53:53 +00:00
}
}
#
2009-02-10 19:48:29 +00:00
# Generate id_rsa.pub, if it does not exist or the force option
2008-01-22 18:53:53 +00:00
#
my $pubfile = "$::root/.ssh/id_rsa.pub";
my $rsafile = "$::root/.ssh/id_rsa";
2008-06-11 18:45:47 +00:00
if ((!-r $pubfile) || $::FORCE)
{
if ($::FORCE)
{
2008-01-22 18:53:53 +00:00
# remove the old file
2008-01-23 17:48:33 +00:00
my $cmd = "/bin/rm $::root/.ssh/id_rsa*";
2008-01-22 18:53:53 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message(
'E',
"Could not remove id_rsa files from $::root/.ssh directory.\n"
);
}
else
2008-01-22 18:53:53 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('I',
"Removed id_rsa files from $::root/.ssh directory.\n");
2008-01-22 18:53:53 +00:00
}
}
2008-06-11 18:45:47 +00:00
my $cmd = "/usr/bin/ssh-keygen -t rsa -q -b 2048 -N '' -f $rsafile";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "Could not generate $pubfile.\n");
}
else
{
xCAT::MsgUtils->message('I', "Generated $pubfile.\n");
2009-02-10 19:48:29 +00:00
if ($::osname eq 'AIX')
{
# allows node be able to scp to the MN only for AIX
my $cmd = "/bin/cat $pubfile >> /.ssh/authorized_keys";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
2008-06-11 18:45:47 +00:00
"Could not cat $pubfile to /.ssh/authorized_keys.\n");
2009-02-10 19:48:29 +00:00
}
else
{
xCAT::MsgUtils->message('I',
2008-06-11 18:45:47 +00:00
"Added $pubfile to /.ssh/authorized_keys.\n");
2009-02-10 19:48:29 +00:00
chmod 0600, "/.ssh/authorized_keys";
}
}
2008-06-11 18:45:47 +00:00
}
2008-01-22 18:53:53 +00:00
}
2009-02-10 19:48:29 +00:00
2008-10-09 15:28:47 +00:00
# copy authorized_keys for install on node
2009-02-10 19:48:29 +00:00
if (-r $pubfile)
{
my $cmd = "/bin/cp $pubfile /install/postscripts/_ssh/authorized_keys";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message(
'E',
"Could not copy $pubfile to /install/postscripts/_ssh/authorized_keys.\n"
);
}
else
{
xCAT::MsgUtils->message('I',
"Copied $pubfile to /install/postscripts/_ssh/authorized_keys.\n");
}
}
else
{
xCAT::MsgUtils->message(
'E',
"Could not copy $pubfile to /install/postscripts/_ssh/authorized_keys,because $pubfile does not exist.\n"
);
2008-10-09 15:28:47 +00:00
}
2008-01-22 18:53:53 +00:00
#
2008-06-11 18:45:47 +00:00
# create /var/log/consoles if needed
2008-01-22 18:53:53 +00:00
#
2008-06-11 18:45:47 +00:00
if (!-d "/var/log/consoles")
{
my $cmd = "/bin/mkdir -p /var/log/consoles";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not create /var/log/consoles directory.\n");
}
else
{
xCAT::MsgUtils->message('I', "Created /var/log/consoles directory.\n");
}
2008-01-22 18:53:53 +00:00
}
# some Linux-only config
2008-06-11 18:45:47 +00:00
if ($::osname eq 'Linux')
{
2008-01-22 18:53:53 +00:00
2008-06-11 18:45:47 +00:00
my $changed_exports = 0;
2008-01-22 18:53:53 +00:00
2008-06-11 18:45:47 +00:00
#
# add tftpboot to /etc/exports - if needed
#
2008-01-22 18:53:53 +00:00
2008-06-11 18:45:47 +00:00
my $cmd = "/bin/cat /etc/exports | grep '/tftpboot'";
my $outref = xCAT::Utils->runcmd("$cmd", -1);
if ($::RUNCMD_RC != 0)
2008-01-22 18:53:53 +00:00
{
2008-06-11 18:45:47 +00:00
# ok - then add this entry
#SECURITY: this has potential for sharing private host/user keys
my $cmd =
"/bin/echo '/tftpboot *(rw,root_squash,sync)' >> /etc/exports";
2008-01-22 18:53:53 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not update the /etc/exports file.\n");
}
else
2008-01-22 18:53:53 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('I',
"Added /tftpboot to the /etc/exports file.\n");
$changed_exports++;
2008-01-22 18:53:53 +00:00
}
2008-06-11 18:45:47 +00:00
}
2008-01-22 18:53:53 +00:00
2008-06-11 18:45:47 +00:00
#
2008-01-22 18:53:53 +00:00
# add /install to /etc/exports - if needed
#
2008-01-23 17:48:33 +00:00
my $cmd = "/bin/cat /etc/exports | grep '/install'";
2008-01-22 18:53:53 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", -1);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
2008-01-22 18:53:53 +00:00
{
2008-06-11 18:45:47 +00:00
2008-01-22 18:53:53 +00:00
# ok - then add this entry
#SECURITY: this has potential for sharing private host/user keys
2008-06-11 18:45:47 +00:00
my $cmd =
"/bin/echo '/install *(ro,no_root_squash,sync)' >> /etc/exports";
2008-01-22 18:53:53 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not update the /etc/exports file.\n");
}
else
2008-01-22 18:53:53 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('I',
"Added /install to the /etc/exports file.\n");
$changed_exports++;
2008-01-22 18:53:53 +00:00
}
}
2008-06-11 18:45:47 +00:00
if ($changed_exports)
{
2008-01-22 18:53:53 +00:00
2008-06-11 18:45:47 +00:00
# restart nfs
my $cmd = "/sbin/service nfs restart";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
my $cmd = "/sbin/chkconfig nfs on";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "Could not enable NFS.\n");
}
else
2008-01-22 18:53:53 +00:00
{
xCAT::MsgUtils->message('I', "NFS has been restarted.\n");
2008-06-11 18:45:47 +00:00
}
}
} # - some Linux-only config
2008-01-22 18:53:53 +00:00
#
2008-06-11 18:45:47 +00:00
# create basic site definition
2008-01-22 18:53:53 +00:00
#
my $hname = `hostname`;
chomp $hname;
# some values common to both AIX & Linux
2008-06-11 18:45:47 +00:00
my $xcatport = "3001";
my $xcatiport = "3002";
my $tftpdir = "/tftpboot";
2008-01-22 18:53:53 +00:00
my $installdir = "/install";
my ($name, $aliases, $addrtype, $length, @addrs) = gethostbyname($hname);
my $master = inet_ntoa($addrs[0]);
# set value based on OS
my ($domain, $timezone);
2008-06-11 18:45:47 +00:00
if ($::osname eq 'AIX')
{
($domain = $hname) =~ s/^.*?\.//;
$timezone = $ENV{'TZ'};
}
else
{
2008-01-22 18:53:53 +00:00
$domain = `hostname -d`;
2008-06-11 18:45:47 +00:00
my $tz;
if (-f "/etc/redhat-release")
{
# on Redhat look for "ZONE"
$tz = `grep ^ZONE /etc/sysconfig/clock|cut -d= -f 2|sed -e 's/"//g'`;
}
else
{
# on SuSE look for "TIMEZONE"
$tz =
`grep ^TIMEZONE /etc/sysconfig/clock|cut -d= -f 2|sed -e 's/"//g'`;
}
2008-01-22 18:53:53 +00:00
$timezone = $tz;
}
chomp $timezone;
chomp $master;
chomp $domain;
# create basic site definition
2008-06-11 18:45:47 +00:00
if ((!-r "/etc/xcat/site.sqlite") || $::FORCE)
{
my $chtabcmds;
$chtabcmds = "$::XCATROOT/sbin/chtab key=xcatdport site.value=$xcatport;";
$chtabcmds .= "$::XCATROOT/sbin/chtab key=xcatiport site.value=$xcatiport;";
$chtabcmds .= "$::XCATROOT/sbin/chtab key=tftpdir site.value=$tftpdir;";
$chtabcmds .=
"$::XCATROOT/sbin/chtab key=installdir site.value=$installdir;";
$chtabcmds .= "$::XCATROOT/sbin/chtab key=master site.value=$master;";
$chtabcmds .= "$::XCATROOT/sbin/chtab key=domain site.value=$domain;";
if ($::osname eq 'Linux')
{
$chtabcmds .=
"$::XCATROOT/sbin/chtab key=timezone site.value=$timezone";
}
if ($::osname eq 'AIX')
{
2009-02-10 19:48:29 +00:00
$chtabcmds .= "$::XCATROOT/sbin/chtab key=useSSHonAIX site.value=no;";
2008-10-29 19:55:30 +00:00
$chtabcmds .=
"$::XCATROOT/sbin/chtab key=consoleondemand site.value=yes;";
2008-06-11 18:45:47 +00:00
}
2008-01-22 18:53:53 +00:00
my $outref = xCAT::Utils->runcmd("$chtabcmds", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
2008-01-22 18:53:53 +00:00
{
xCAT::MsgUtils->message('E', "Could not create site definition.\n");
2008-06-11 18:45:47 +00:00
}
else
{
2008-01-22 18:53:53 +00:00
xCAT::MsgUtils->message('I', "Updated cluster site definition.\n");
}
}
2009-02-10 19:48:29 +00:00
# create default postscript list in postscripts table
2008-06-11 18:45:47 +00:00
if ((!-r "/etc/xcat/postscripts.sqlite") || $::FORCE)
{
2008-04-15 12:53:58 +00:00
my $chtabcmds;
2008-06-12 17:15:05 +00:00
if ($::osname eq 'AIX')
{
2009-02-10 19:48:29 +00:00
$chtabcmds =
"$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts='syslog,aixremoteshell';";
2008-06-12 17:15:05 +00:00
}
else
{
2009-02-10 19:48:29 +00:00
$chtabcmds =
"$::XCATROOT/sbin/chtab node=xcatdefaults postscripts.postscripts='syslog,remoteshell';";
2008-06-12 17:15:05 +00:00
}
2008-06-11 18:45:47 +00:00
$chtabcmds .=
"$::XCATROOT/sbin/chtab node=service postscripts.postscripts='servicenode';";
2008-04-15 12:53:58 +00:00
my $outref = xCAT::Utils->runcmd("$chtabcmds", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not create postscripts definition.\n");
}
else
2008-04-15 12:53:58 +00:00
{
xCAT::MsgUtils->message('I', "Created postscripts definition.\n");
}
}
2008-01-22 18:53:53 +00:00
# create basic policy definition.
2008-06-11 18:45:47 +00:00
if ((!-r "/etc/xcat/policy.sqlite") || $::FORCE)
{
my $chtabcmds;
if ($::osname eq 'AIX')
{
$chtabcmds =
"$::XCATROOT/sbin/chtab priority=1 policy.name=root policy.rule=allow;";
$chtabcmds .=
"$::XCATROOT/sbin/chtab priority=4.4 policy.commands=getpostscript policy.rule=allow;";
$chtabcmds .=
"$::XCATROOT/sbin/chtab priority=4.5 policy.commands=getcredentials policy.rule=allow";
}
else
{
$chtabcmds =
"$::XCATROOT/sbin/chtab priority=1 policy.name=root policy.rule=allow;";
$chtabcmds .=
"$::XCATROOT/sbin/chtab priority=2 policy.commands=getbmcconfig policy.rule=allow;";
$chtabcmds .=
"$::XCATROOT/sbin/chtab priority=3 policy.commands=nextdestiny policy.rule=allow;";
$chtabcmds .=
"$::XCATROOT/sbin/chtab priority=4 policy.commands=getdestiny policy.rule=allow;";
$chtabcmds .=
"$::XCATROOT/sbin/chtab priority=4.4 policy.commands=getpostscript policy.rule=allow;";
$chtabcmds .=
"$::XCATROOT/sbin/chtab priority=4.5 policy.commands=getcredentials policy.rule=allow";
}
2008-01-22 18:53:53 +00:00
my $outref = xCAT::Utils->runcmd("$chtabcmds", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
2008-01-22 18:53:53 +00:00
{
xCAT::MsgUtils->message('E', "Could not create policy definition.\n");
2008-06-11 18:45:47 +00:00
}
else
{
2008-01-22 18:53:53 +00:00
xCAT::MsgUtils->message('I', "Created policy definition.\n");
}
}
2008-03-04 14:24:06 +00:00
#
# set up syslog
#
2008-05-29 13:50:12 +00:00
# (use postscript to set up syslog -- leaving old code for now in case it
# did something differnt)
2008-06-11 18:45:47 +00:00
my $cmd = "/install/postscripts/syslog";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "Could not set up syslog.\n");
}
else
{
xCAT::MsgUtils->message('I', "syslog has been set up.\n");
}
2008-05-29 13:50:12 +00:00
# <old syslog setup code -- delete after new code is well verified>
# if backup file exists assume it's already set up
#if (( ! -r "/etc/syslog.conf.ORIG" ) || $::FORCE) {
# my $syslogcmds;
# $syslogcmds = "cp /etc/syslog.conf /etc/syslog.conf.ORIG;";
# $syslogcmds .= "echo '*.debug /var/log/localmessages' > /etc/test.tmp;";
# $syslogcmds .= "echo '*.crit /var/log/localmessages' >> /etc/test.tmp;";
# $syslogcmds .= "cat /etc/test.tmp >> /etc/syslog.conf;";
# $syslogcmds .= "rm /etc/test.tmp;";
# $syslogcmds .= "touch /var/log/localmessages;";
# if ($::osname eq 'AIX') {
# $syslogcmds .= "stopsrc -s syslogd;";
# $syslogcmds .= "startsrc -s syslogd;";
# } else {
2008-10-17 17:59:57 +00:00
# $syslogcmds .= "/etc/init.d/syslog stop;";
# $syslogcmds .= "/etc/init.d/syslog start;";
2008-05-29 13:50:12 +00:00
# }
#
# my $outref = xCAT::Utils->runcmd("$syslogcmds", 0);
# if ($::RUNCMD_RC != 0)
# {
# xCAT::MsgUtils->message('E', "Could not set up syslog.\n");
# } else {
# xCAT::MsgUtils->message('I', "Started syslog daemon.\n");
# }
#}
2008-02-18 13:14:29 +00:00
2008-01-22 18:53:53 +00:00
#
2008-06-11 18:45:47 +00:00
# set up the certificates for xcatd
2008-01-22 18:53:53 +00:00
#
2008-06-11 18:45:47 +00:00
if ((!-d "/etc/xcat/ca") || $::FORCE)
{
xCAT::MsgUtils->message(
'I',
"\nSetting up basic certificates. Respond with a \'y\' when prompted.\n\n"
);
my $cmd =
"echo 'y\ny\ny\ny' |$::XCATROOT/share/xcat/scripts/setup-xcat-ca.sh 'xCAT CA'";
xCAT::MsgUtils->message('I', "Running $cmd\n");
my $rc = system($cmd);
if ($rc >> 8)
{
xCAT::MsgUtils->message('E',
"Could not create xCAT certificate in /etc/xcat/ca.\n");
}
else
{
2008-01-22 18:53:53 +00:00
xCAT::MsgUtils->message('I', "Created xCAT certificate.\n");
}
}
2008-06-11 18:45:47 +00:00
2008-05-29 13:50:12 +00:00
# copy to postscript directory
2008-06-11 18:45:47 +00:00
my $cmd = "/bin/rm -rf /install/postscripts/ca &2>/dev/null";
2008-05-29 13:50:12 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-10-09 14:13:56 +00:00
my $cmd = "/bin/mkdir -p /install/postscripts/ca/certs";
2008-05-29 13:50:12 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
2009-02-10 19:48:29 +00:00
"Could not create /install/postscripts/ca/certs directory.\n");
2008-06-11 18:45:47 +00:00
}
else
2008-05-29 13:50:12 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('I',
2009-02-10 19:48:29 +00:00
"Created /install/postscripts/ca/certs directory.\n");
2008-05-29 13:50:12 +00:00
}
my $cmd = "/bin/cp -r /etc/xcat/ca/* /install/postscripts/ca";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
2008-05-29 13:50:12 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message(
'E',
"Could not copy /etc/xcat/ca/* to /install/postscripts/ca directory.\n"
);
}
else
{
xCAT::MsgUtils->message('I',
"Copied /etc/xcat/ca/* to /install/postscripts/ca directory.\n");
2008-05-29 13:50:12 +00:00
}
2008-01-22 18:53:53 +00:00
2008-06-11 18:45:47 +00:00
if ((!-d "/etc/xcat/cert") || $::FORCE)
{
my $cmd =
"echo 'y\ny\ny\ny' |$::XCATROOT/share/xcat/scripts/setup-server-cert.sh $hname";
2008-05-29 13:50:12 +00:00
xCAT::MsgUtils->message('I', "Running $cmd\n");
2008-06-11 18:45:47 +00:00
my $rc = system($cmd);
2008-01-25 17:40:04 +00:00
if ($rc >> 8)
2008-01-22 18:53:53 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('E',
"Could not create xCAT certificate in /etc/xcat/cert.\n");
}
else
{
2008-01-22 18:53:53 +00:00
xCAT::MsgUtils->message('I', "Created xCAT certificate.\n");
}
}
2008-06-11 18:45:47 +00:00
2008-05-29 13:50:12 +00:00
# copy to postscript directory
2008-06-11 18:45:47 +00:00
my $cmd = "/bin/rm -rf /install/postscripts/cert &2>/dev/null";
2008-05-29 13:50:12 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
my $cmd = "/bin/mkdir -p /install/postscripts/cert";
2008-05-29 13:50:12 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
2008-05-29 13:50:12 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('E',
"Could not create /install/postscripts/cert directory.\n");
}
else
{
xCAT::MsgUtils->message('I',
"Created /install/postscripts/cert directory.\n");
2008-05-29 13:50:12 +00:00
}
my $cmd = "/bin/cp -r /etc/xcat/cert/* /install/postscripts/cert";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
2008-05-29 13:50:12 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message(
'E',
"Could not copy /etc/xcat/cert/* to /install/postscripts/cert directory.\n"
);
}
else
{
xCAT::MsgUtils->message('I',
"Copied /etc/xcat/cert/* to /install/postscripts/cert directory.\n");
2008-05-29 13:50:12 +00:00
}
2008-06-11 18:45:47 +00:00
if ((!-r "$::root/.xcat/client-key.pem") || $::FORCE)
{
2008-01-22 18:53:53 +00:00
2008-06-11 18:45:47 +00:00
my $cmd =
"echo 'y\ny\ny\ny' |$::XCATROOT/share/xcat/scripts/setup-local-client.sh root";
xCAT::MsgUtils->message('I', "Running $cmd\n");
my $rc = system($cmd);
2008-01-25 17:40:04 +00:00
if ($rc >> 8)
2008-01-22 18:53:53 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('E',
"Could not create xCAT certificate in /.xcat/client-key.pem.\n");
}
else
{
2008-01-22 18:53:53 +00:00
xCAT::MsgUtils->message('I', "Created xCAT certificate.\n");
}
}
2008-06-11 18:45:47 +00:00
2008-05-29 13:50:12 +00:00
# copy to postscript directory
2008-06-11 18:45:47 +00:00
my $cmd = "/bin/rm -rf /install/postscripts/_xcat &2>/dev/null";
2008-05-29 13:50:12 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
my $cmd = "/bin/mkdir -p /install/postscripts/_xcat";
2008-05-29 13:50:12 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
2008-05-29 13:50:12 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('E',
"Could not create /install/postscripts/_xcat directory.\n");
}
else
{
xCAT::MsgUtils->message('I',
"Created /install/postscripts/_xcat directory.\n");
2008-05-29 13:50:12 +00:00
}
my $cmd = "/bin/cp -r $::root/.xcat/* /install/postscripts/_xcat";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
2008-05-29 13:50:12 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message(
'E',
"Could not copy $::root/.xcat/* to /install/postscripts/_xcat directory.\n"
);
}
else
{
xCAT::MsgUtils->message('I',
"Copied $::root/.xcat/* to /install/postscripts/_xcat directory.\n");
2008-05-29 13:50:12 +00:00
}
2008-10-09 14:13:56 +00:00
my $cmd = "/bin/cp -r /etc/xcat/ca/certs/* /install/postscripts/ca/certs";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message(
'E',
"Could not copy /etc/xcat/ca/certs/* to /install/postscripts/ca/certs directory.\n"
);
}
else
{
2009-02-10 19:48:29 +00:00
xCAT::MsgUtils->message(
'I',
"Copied /etc/xcat/ca/certs* to /install/postscripts/ca/certs directory.\n"
);
2008-10-09 14:13:56 +00:00
}
2008-01-22 18:53:53 +00:00
#
2008-02-18 16:38:09 +00:00
# if there are xcatd processes then stop them
2008-01-22 18:53:53 +00:00
#
2008-02-18 16:38:09 +00:00
my @xpids = xCAT::Utils->runcmd("ps -ef\|grep \"xcatd\"", 0);
2008-06-11 18:45:47 +00:00
if ($#xpids >= 1)
{ # will have at least "0" for the grep
xCAT::MsgUtils->message('I', "Stopping xcatd processes....\n");
foreach $ps (@xpids)
{
$ps =~ s/^\s+//; # strip any leading spaces
my ($uid, $pid, $ppid, $desc) = split /\s+/, $ps;
# if $ps contains "grep" then it's not one of the daemon processes
if ($ps !~ /grep/)
{
# print "pid=$pid\n";
my $cmd = "/bin/kill -9 $pid";
xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not stop xcatd process $pid.\n");
}
}
}
2008-01-22 18:53:53 +00:00
}
#
# start xcatd
#
xCAT::MsgUtils->message('I', "Starting xcatd.....\n");
my $xcmd;
2008-06-11 18:45:47 +00:00
if ($::osname eq 'AIX')
{
$xcmd = "$::XCATROOT/sbin/xcatd &";
}
else
{
$xcmd = "/etc/init.d/xcatd start";
2008-01-22 18:53:53 +00:00
}
my $outref = xCAT::Utils->runcmd("$xcmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
2008-01-22 18:53:53 +00:00
{
2008-06-11 18:45:47 +00:00
xCAT::MsgUtils->message('E', "Could not start xcatd.\n");
}
2008-01-22 18:53:53 +00:00
2008-11-19 15:22:21 +00:00
# for AIX systems add xcatd to the /etc/inittab file
if ($::osname eq 'AIX')
{
2009-02-10 19:48:29 +00:00
my $mkitab_cmd =
'mkitab "xcatd:2:once:/opt/xcat/sbin/xcatd > /dev/console 2>&1" > /dev/null 2>&1';
my $rc = system($mkitab_cmd);
2008-11-19 15:22:21 +00:00
}
2008-01-22 18:53:53 +00:00
# more - Linux-only config
2008-06-11 18:45:47 +00:00
if ($::osname eq 'Linux')
{
#Zap the almost certainly wrong pxelinux.cfg file
if (-f "/tftpboot/pxelinux.cfg/default")
{
$cmd = "/bin/rm /tftpboot/pxelinux.cfg/default";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"Could not remove /tftpboot/pxelinux.cfg/default\n");
}
else
{
xCAT::MsgUtils->message('I',
"Removed /tftpboot/pxelinux.cfg/default.\n");
}
}
# run mknb
if ($::arch eq "x86_64")
{
my $cmd = "$::XCATROOT/sbin/mknb x86_64";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"The mknb x86_64 command returned error: $::RUNCMD_RC.\n");
}
else
{
xCAT::MsgUtils->message('I',
"The mknb x86_64 command was run with no error.\n");
}
}
if ($::arch eq "ppc64")
{
my $cmd = "$::XCATROOT/sbin/mknb ppc64";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"The mknb ppc64 command returned error: $::RUNCMD_RC.\n");
}
else
{
xCAT::MsgUtils->message('I',
"The mknb ppc64 command was run with no error.\n");
}
}
# run makenetworks
my $cmd = "$::XCATROOT/sbin/makenetworks";
2008-01-22 18:53:53 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
2008-06-11 18:45:47 +00:00
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"The makenetworks command returned error: $::RUNCMD_RC.\n");
}
else
{
xCAT::MsgUtils->message('I',
"The makenetworks command was run with no error.\n");
}
# set the nameserver in the site table
my @names =
xCAT::Utils->runcmd(
"/bin/grep nameserver /etc/resolv.conf | cut -d' ' -f 2",
0);
my $ns = join(',', @names);
my $cmd = "$::XCATROOT/sbin/chtab key=nameservers site.value=$ns";
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E',
"The chtab command returned error: $::RUNCMD_RC.\n");
}
else
{
xCAT::MsgUtils->message('I',
"Updated the site definition with the value of the nameserver.\n");
}
# restart httpd
2009-02-16 10:33:01 +00:00
my $cmd;
if(-e "/etc/init.d/apache2") {#for sles
$cmd = "/etc/init.d/apache2 stop; /etc/init.d/apache2 start";
}else {
$cmd = "/etc/init.d/httpd stop; /etc/init.d/httpd start";
}
2008-06-11 18:45:47 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message('E', "Could not restart httpd.\n");
}
else
{
xCAT::MsgUtils->message('I', "httpd has been restarted.\n");
}
# enable httpd
2009-02-16 10:33:01 +00:00
if(-e "/etc/init.d/apache2") {#for sles
$cmd = "/sbin/chkconfig apache2 on";
}else {
$cmd = "/sbin/chkconfig httpd on";
}
2008-06-11 18:45:47 +00:00
my $outref = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
2008-01-22 18:53:53 +00:00
{
xCAT::MsgUtils->message('E', "Could not enable httpd.\n");
2008-06-11 18:45:47 +00:00
}
else
{
2008-01-22 18:53:53 +00:00
xCAT::MsgUtils->message('I', "httpd has been enabled.\n");
}
2008-06-11 18:45:47 +00:00
my $linux_note =
"xCAT is now installed, it is recommended to tabedit networks \nand set a dynamic ip address range on any networks where nodes \nare to be discovered. Then, run makedhcp -n to create a new dhcpd \nconfiguration file, and \/etc\/init.d\/dhcpd restart. Either examine sample \nconfiguration templates, or write your own, or specify a value per \nnode with nodeadd or tabedit.\n";
xCAT::MsgUtils->message('I', $linux_note);
2008-01-22 18:53:53 +00:00
2008-06-11 18:45:47 +00:00
} #End - more - Linux-only config
2008-01-22 18:53:53 +00:00
exit;
#####################################
# subroutines
#####################################
2008-06-11 18:45:47 +00:00
sub usage
{
xCAT::MsgUtils->message('I', "Usage:\n");
xCAT::MsgUtils->message(
'I',
"xcatconfig - Performs basic xCAT configuration on an xCAT management node.\n\n"
);
xCAT::MsgUtils->message('I', " xcatconfig [-h|--help] [-f|--force]\n\n");
2008-01-22 18:53:53 +00:00
}