1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # $Id$
|
---|
4 | #
|
---|
5 | # Gives the right driver to use for HP Smart Array Controllers for the corresponding Linux distribution
|
---|
6 | # Vased on the HP document hpsa migration at
|
---|
7 | #
|
---|
8 | use strict;
|
---|
9 |
|
---|
10 | my $drv = {
|
---|
11 | "P420i"
|
---|
12 | }
|
---|
13 |
|
---|
14 | # Handling Configuration files
|
---|
15 | my $tool = "";
|
---|
16 | my $ret = 0;
|
---|
17 | my $productname = undef;
|
---|
18 |
|
---|
19 | die "You need dmidecode for Hardware support\n" if (! -x "/usr/sbin/dmidecode");
|
---|
20 |
|
---|
21 | mkdir $bkpdir,0755 if (! -d $bkpdir) ;
|
---|
22 | open(SYSTEM,"/usr/sbin/dmidecode -s 'system-product-name' 2> /dev/null |") || die "You need /usr/sbin/dmidecode for mindi hardware support";
|
---|
23 | while (<SYSTEM>) {
|
---|
24 | next if (/^#/);
|
---|
25 | $productname = $_;
|
---|
26 | chomp($productname);
|
---|
27 | }
|
---|
28 | close(SYSTEM);
|
---|
29 |
|
---|
30 | die "INFO: No product name found for Hardware support\n" if (not defined $productname);
|
---|
31 |
|
---|
32 | if ($productname =~ /proliant/i) {
|
---|
33 | print "Detected a $productname. Nice. Continue to support my job :-)\n";
|
---|
34 | print "Activating ProLiant support for mindi\n";
|
---|
35 | print "You can install SDR packages to benefit from mindi's enhanced ProLiant support\n";
|
---|
36 | print "Get them from http://downloads.linux.hp.com/SDR/\n";
|
---|
37 | open(PROLIANT,"$confdir/deplist.d/ProLiant.conf") || die "Unable to open $confdir/deplist.d/ProLiant.conf";
|
---|
38 | # generate a list of what need to be put on the backup media
|
---|
39 | open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
|
---|
40 | # generate a script that will be launched at rstore time to perform the HW setup
|
---|
41 | open(SCRIPT,"> $bkpdir/../mindi-rsthw") || die "Unable to open $bkpdir/../mindi-rsthw";
|
---|
42 | print SCRIPT << 'EOF';
|
---|
43 | #!/bin/bash
|
---|
44 | #
|
---|
45 | # Script generated by mindi
|
---|
46 | #
|
---|
47 | # This script will restore potentially your HW configuration
|
---|
48 | # on your system before partioning occurs.
|
---|
49 | #
|
---|
50 | # You may want to reboot after that step if you think that
|
---|
51 | # resetting BIOS parameters to the value restored
|
---|
52 | # may have an impact on your restoration process or if
|
---|
53 | # you want to benefit from any firmware update that could have happened.
|
---|
54 | #
|
---|
55 | EOF
|
---|
56 | while($tool = <PROLIANT>) {
|
---|
57 | my $hasfound = 0;
|
---|
58 | next if ($tool =~ /^#/);
|
---|
59 | chomp($tool);
|
---|
60 | # skip non-executable/exising binaries
|
---|
61 | if (! (-x $tool)) {
|
---|
62 | next;
|
---|
63 | } else {
|
---|
64 | print "Found $tool, activating enhanced HP ProLiant support in mindi\n";
|
---|
65 | print TOOLS "$tool\n";
|
---|
66 | }
|
---|
67 | if ($tool =~ /\/conrep$/) {
|
---|
68 | my $xmlf = "/opt/hp/hp-scripting-tools/etc/conrep.xml";
|
---|
69 | # From the package
|
---|
70 | if (-f $xmlf) {
|
---|
71 | $ret = system("$tool -s -x $xmlf -f$bkpdir/conrep.dat");
|
---|
72 | # From the SSSTK
|
---|
73 | } else {
|
---|
74 | $xmlf = "/usr/share/conrep/conrep.xml";
|
---|
75 | if (-f $xmlf) {
|
---|
76 | $ret = system("$tool -s -x $xmlf -f$bkpdir/conrep.dat");
|
---|
77 | } else {
|
---|
78 | next;
|
---|
79 | }
|
---|
80 | }
|
---|
81 | print SCRIPT "$tool -l -f$locbkpdir/conrep.dat\n";
|
---|
82 | print TOOLS "$xmlf\n";
|
---|
83 | }
|
---|
84 | if ($tool =~ /\/hp-rcu$/) {
|
---|
85 | $ret = system("$tool -s -f$bkpdir/conrep.dat");
|
---|
86 | print SCRIPT "$tool -l -f$locbkpdir/conrep.dat\n";
|
---|
87 | }
|
---|
88 | if ($tool =~ /\/hpacuscripting$/) {
|
---|
89 | $hasfound = 1;
|
---|
90 | my $dir=basename($tool);
|
---|
91 | # Just backup internal info for a DR
|
---|
92 | $ret = system("$tool -c $bkpdir/hpacuscripting.dat -internal");
|
---|
93 | # We could want to reset it before.
|
---|
94 | print SCRIPT "# $tool -reset -i $locbkpdir/hpacusripting.dat\n";
|
---|
95 | print SCRIPT "$tool -i $locbkpdir/hpacusripting.dat\n";
|
---|
96 | }
|
---|
97 | if ($tool =~ /\/hponcfg$/) {
|
---|
98 | $ret = system("$tool -a -w $bkpdir/hponcfg.dat");
|
---|
99 | print SCRIPT "$tool -f $locbkpdir/hponcfg.dat\n";
|
---|
100 | }
|
---|
101 | if ($tool =~ /\.scexe$/) {
|
---|
102 | print "Found $tool, that firmware will be applied at restore time on your HP ProLiant\n";
|
---|
103 | print SCRIPT "./$tool -s\n";
|
---|
104 | }
|
---|
105 | if ($tool =~ /\/hp-fm/) {
|
---|
106 | print "Found $tool, firmware will be upgraded at restore time on your HP ProLiant\n";
|
---|
107 | print SCRIPT "./$tool upgrade\n";
|
---|
108 | }
|
---|
109 | # Kept for compatibility with older version of tools
|
---|
110 | if (($tool =~ /\/hpacucli$/) && ($hasfound == 0)) {
|
---|
111 | my $dir=basename($tool);
|
---|
112 | $ret = system("$tool -c $bkpdir/hpacucli.dat");
|
---|
113 | print SCRIPT "$tool -i $locbkpdir/hpacucli.dat\n";
|
---|
114 | }
|
---|
115 | if ($ret != 0) {
|
---|
116 | print "$tool returned an error. Hardware support may not be complete\n";
|
---|
117 | }
|
---|
118 | }
|
---|
119 | close(PROLIANT);
|
---|
120 | close(TOOLS);
|
---|
121 | close(SCRIPT);
|
---|
122 | } else {
|
---|
123 | print "INFO: No Hardware optimized support for your product $productname\n";
|
---|
124 | print " You may ask your manufacturer to contribute to the mindi project\n for firmware Disaster Recovery support (harmless)\n";
|
---|
125 | }
|
---|
126 | rmdir $bkpdir if (-d $bkpdir) ;
|
---|