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