549078cdd5
new database like postgresql. Replaces the manual setup now in the Cookbook ( all the chtabs). Can expand in the future do do the entire db setup. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@766 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
75 lines
2.0 KiB
Perl
75 lines
2.0 KiB
Perl
#!/usr/bin/perl
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
#egan@us.ibm.com
|
|
#(C)IBM Corp
|
|
|
|
#
|
|
|
|
BEGIN
|
|
{
|
|
$::XCATROOT =
|
|
$ENV{'XCATROOT'} ? $ENV{'XCATROOT'}
|
|
: -d '/opt/xcat' ? '/opt/xcat'
|
|
: '/usr';
|
|
}
|
|
use lib "$::XCATROOT/lib/perl";
|
|
use File::Basename;
|
|
use Getopt::Long;
|
|
use xCAT::MsgUtils;
|
|
use xCAT::Utils;
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
=head1 init_xcatdb
|
|
|
|
This routine initializes a new database with the default values in the site
|
|
table and necessary credentials for the xcatd daemon to run.
|
|
|
|
=cut
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
my $rc = &init_db;
|
|
|
|
exit $rc;
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
=head3 init_db
|
|
|
|
|
|
=cut
|
|
|
|
#-----------------------------------------------------------------------------
|
|
sub init_db
|
|
{
|
|
my $rc = 0;
|
|
my @timezone = `grep ZONE /etc/sysconfig/clock|cut -d= -f 2`;
|
|
my $hostname = `hostname`;
|
|
my $masterhost = `getent hosts $hostname`;
|
|
my ($masterip, $mastername) = split ' ', $masterhost;
|
|
my $domain = `hostname -d`;
|
|
my @cmd = (
|
|
"chtab key=xcatdport site.value=3001",
|
|
"chtab key=master site.value=$masterip",
|
|
"chtab key=tftpdir site.value=/tftpboot",
|
|
"chtab key=domain site.value=$domain",
|
|
"chtab key=timezone site.value=$timezone[0]",
|
|
"chtab key=installdir site.value=/install",
|
|
"chtab priority=1 policy.name=root policy.rule=allow",
|
|
"chtab priority=2 policy.commands=getbmcconfig policy.rule=allow",
|
|
"chtab priority=3 policy.commands=nextdestiny policy.rule=allow",
|
|
"chtab priority=4 policy.commands=getdestiny policy.rule=allow"
|
|
);
|
|
foreach $cmd (@cmd)
|
|
{
|
|
my @output = xCAT::Utils->runcmd($cmd, 0);
|
|
if ($::RUNCMD_RC != 0)
|
|
{
|
|
xCAT::MsgUtils->message("E", "Error from $cmd, @output");
|
|
}
|
|
}
|
|
|
|
return $rc;
|
|
}
|