From 549078cdd51df0006c33b073f79a328fa3a7c4f2 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 12 Mar 2008 13:34:51 +0000 Subject: [PATCH] This routine will initiate the site table and policy table for a 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 --- xCAT-server-2.0/sbin/init_xcatdb | 74 ++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 xCAT-server-2.0/sbin/init_xcatdb diff --git a/xCAT-server-2.0/sbin/init_xcatdb b/xCAT-server-2.0/sbin/init_xcatdb new file mode 100644 index 000000000..ee57067bc --- /dev/null +++ b/xCAT-server-2.0/sbin/init_xcatdb @@ -0,0 +1,74 @@ +#!/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; +}