[925] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # Backup the hardware configuration on machine supporting it
|
---|
| 4 | # (Bios configuration, Raid configuration, ...)
|
---|
| 5 | #
|
---|
[1280] | 6 | use strict;
|
---|
[1469] | 7 | use File::Basename;
|
---|
[925] | 8 |
|
---|
[1280] | 9 | # Handling Configuration files
|
---|
[1770] | 10 | die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
|
---|
| 11 | my $bkpdir = "$ARGV[0]/bkphw";
|
---|
| 12 | die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
|
---|
| 13 | my $confdir = "$ARGV[1]";
|
---|
| 14 |
|
---|
[1280] | 15 | my $tool = "";
|
---|
[1469] | 16 | my $tooldir = "";
|
---|
[1280] | 17 | my $ret = 0;
|
---|
[925] | 18 |
|
---|
[1770] | 19 | mkdir $bkpdir,0755 if (! -d $bkpdir) ;
|
---|
[1280] | 20 | open(SYSTEM,"dmidecode -s 'system-product-name' |") || die "You need dmidecode for mindi hardware support";
|
---|
| 21 | my $productname = <SYSTEM>;
|
---|
| 22 | close(SYSTEM);
|
---|
| 23 |
|
---|
| 24 | chomp($productname);
|
---|
[1467] | 25 | if ($productname =~ /proliant/i) {
|
---|
| 26 | print "Detected an HP Hardware. Nice. Continue to support my job :-)\n";
|
---|
| 27 | print "Activating Proliant support for mindi\n";
|
---|
[1770] | 28 | open(PROLIANT,"$confdir/proliant.files") || die "Unable to open $confdir/proliant.files";
|
---|
| 29 | open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
|
---|
| 30 | open(SCRIPT,"> $bkpdir/../mindi-rsthw") || die "Unable to open $bkpdir/../mindi-rsthw";
|
---|
| 31 | print SCRIPT << "EOF";
|
---|
| 32 | #!/bin/bash
|
---|
| 33 | #
|
---|
| 34 | # This script will restore potentially your HW configuration
|
---|
| 35 | # on your system before partioning occurs
|
---|
| 36 | # You may want to reboot after that step if you think that
|
---|
| 37 | # resetting BIOS parameters to the value restored
|
---|
| 38 | # may have an impact on you restoration process
|
---|
| 39 | #
|
---|
| 40 | EOF
|
---|
[1467] | 41 | while($tool = <PROLIANT>) {
|
---|
| 42 | next if ($tool =~ /^#/);
|
---|
| 43 | chomp($tool);
|
---|
[1469] | 44 | $tooldir = dirname($tool);
|
---|
[1467] | 45 | if (! (-e $tool)) {
|
---|
| 46 | print "You should install the SmartStart Scripting toolkit tool $tool\nto benefit from mindi's enhanced hardware support\n";
|
---|
| 47 | print "Get it from http://www.hp.com/servers/sstoolkit\n";
|
---|
| 48 | next;
|
---|
| 49 | } else {
|
---|
| 50 | print "Found $tool, activating enhanced HP Proliant support in mindi\n";
|
---|
[1770] | 51 | print TOOLS "$tool\n";
|
---|
[1280] | 52 | }
|
---|
[1770] | 53 | if ($tool =~ /\/conrep$/) {
|
---|
| 54 | $ret = system("(cd $tooldir ; $tool -s -f$bkpdir/conrep.dat)");
|
---|
| 55 | print SCRIPT "(cd $tooldir ; $tool -s -f$bkpdir/conrep.dat)");
|
---|
| 56 | print TOOLS "$tool.xml\n";
|
---|
[1467] | 57 | }
|
---|
[1770] | 58 | if ($tool =~ /\/cpqacuxe$/) {
|
---|
| 59 | $ret = system("$tool -c $bkpdir/cpqacuxe.dat");
|
---|
| 60 | print SCRIPT "$tool -r $bkpdir/cpqacuxe.dat");
|
---|
| 61 | print TOOLS "$tooldir/bld\n";
|
---|
[1467] | 62 | }
|
---|
[1770] | 63 | if ($tool =~ /\/hponcfg$/) {
|
---|
| 64 | $ret = system("$tool -w $bkpdir/hponcfg.dat");
|
---|
| 65 | print SCRIPT "$tool -r $bkpdir/hponcfg.dat");
|
---|
[1467] | 66 | }
|
---|
[1770] | 67 | if ($tool =~ /\.scexe$/) {
|
---|
| 68 | print SCRIPT "$tool");
|
---|
| 69 | }
|
---|
[1467] | 70 | if ($ret != 0) {
|
---|
| 71 | print "$tool returned an error. Hardware support may not be complete\n";
|
---|
| 72 | }
|
---|
[1280] | 73 | }
|
---|
[1770] | 74 | close(PROLIANT);
|
---|
| 75 | close(TOOLS);
|
---|
| 76 | close(SCRIPT);
|
---|
[1280] | 77 | } else {
|
---|
| 78 | print "No Hardware support for $productname\n";
|
---|
| 79 | print "Ask your manufacturer to contribute to the mindi project\n";
|
---|
| 80 | }
|
---|
[1770] | 81 | rmdir $bkpdir if (-d $bkpdir) ;
|
---|