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
This commit is contained in:
		@@ -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 (<CFGFILE>)
 | 
			
		||||
        {
 | 
			
		||||
            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;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user