From 0bb00bda1718db83960c629995b27f5cca3154a0 Mon Sep 17 00:00:00 2001 From: xuweibj Date: Wed, 17 Apr 2019 04:28:03 -0400 Subject: [PATCH] Add DB pkgs check on SN for xcatprobe xcatmn --- xCAT-probe/subcmds/xcatmn | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index 612e95620..76b23458d 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -172,6 +172,10 @@ sub do_main_job { $rst = check_dhcp_leases(\$checkpoint, \@error); print_check_result($checkpoint, "w", $rst, \@error); $rc |= $rst; + } else { + $rst = check_db_pkgs(\$checkpoint, \@error); + print_check_result($checkpoint, "f", $rst, \@error); + $rc |= $rst; } cleanup(); @@ -1253,6 +1257,37 @@ sub check_daemon_attributes { return ($rst, $rst_type); } +sub check_db_pkgs { + my $checkpoint_ref = shift; + my $error_ref = shift; + my $rst = 0; + + $$checkpoint_ref = "Checking DB packages installatio..."; + @$error_ref = (); + + my $cfgloc_file = "/etc/xcat/cfgloc"; + if (! -e $cfgloc_file) { + push @$error_ref, "$cfgloc_file does not exist, please check xcat installation."; + return 1; + } + my $db_type = `cat $cfgloc_file | awk -F ':' '{print \$1}'`; + chomp($db_type); + my $db_pkg; + my $db_name; + if ($db_type eq "mysql") { + $db_name = "perl-DBD-MySQL or perl-DBD-mysql"; + $db_pkg = `rpm qa | grep -e perl-DBD-MySQL -e perl-DBD-mysql`; + } elsif ($db_type eq "Pg") { + $db_name = "perl-DBD-Pg"; + $db_pkg = `rpm -qa | grep $db_name`; + } + if (!$db_pkg) { + push @$error_ref, "$db_name is not installed, please install it."; + $rst = 1; + } + return $rst; +} + sub returncmdoutput { my $rst = shift; my $error_ref = shift;