From 0cd7e3c09dc4852c503e9ba8a71a3e6408aa788d Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 12 Mar 2008 15:35:40 +0000 Subject: [PATCH] Add more setup including the creation of the /etc/xcat/cfgloc file. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@767 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/sbin/init_xcatdb | 59 +++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/xCAT-server-2.0/sbin/init_xcatdb b/xCAT-server-2.0/sbin/init_xcatdb index ee57067bc..833f41eef 100644 --- a/xCAT-server-2.0/sbin/init_xcatdb +++ b/xCAT-server-2.0/sbin/init_xcatdb @@ -61,14 +61,63 @@ sub init_db "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) + foreach $cmd (@cmd) { + + my @output = xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) { - xCAT::MsgUtils->message("E", "Error from $cmd, @output"); + xCAT::MsgUtils->message("E", "Error from $cmd, @output"); } } + # build /etc/xcat/cfgloc + my @cfg; + my $cfg2; + my $dbinfo; + my $configfile = "/etc/sysconfig/xcat"; + if (-e ($configfile)) + { + open(CFGFILE, "<$configfile") + or xCAT::MsgUtils->message( + 'S', + "Cannot open $configfile for DB access. Please create using information in the xCAT 2.0 Cookbook ( Setting up postgresql) and rerun this script.\n" + ); + foreach my $line () + { + if (grep /XCATCFG/, $line) + { + @cfg = split /XCATCFG=/, $line; + @cfg2 = split /'/, $cfg[1]; + chomp $cfg2[1]; + $dbinfo = $cfg2[1]; + close CFGFILE; + last; + } + } + if ($dbinfo) + { + `echo "$dbinfo" > /etc/xcat/cfgloc`; + } + else + { + xCAT::MsgUtils->message("E", + "The contents of $configfile is invalid\n"); + } + } + else + { + xCAT::MsgUtils->message( + "E", + "$configfile does not exist, need to create and rerun the script\n" + ); + } + + $cmd = "service xcatd restart"; + my @output = xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message("E", "Error from $cmd, @output"); + } + return $rc; }