#!/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; }