[1761] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # Backup the hardware configuration on machine supporting it
|
---|
| 4 | # (Bios configuration, Raid configuration, ...)
|
---|
| 5 | #
|
---|
| 6 | use strict;
|
---|
| 7 | use File::Basename;
|
---|
| 8 |
|
---|
| 9 | # Handling Configuration files
|
---|
| 10 | my $tool = "";
|
---|
| 11 | my $tooldir = "";
|
---|
| 12 | my $ret = 0;
|
---|
| 13 |
|
---|
| 14 | die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
|
---|
| 15 | my $bkpdir = "$ARGV[0]/bkphw";
|
---|
| 16 | die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
|
---|
| 17 | my $confdir = "$ARGV[1]";
|
---|
| 18 |
|
---|
| 19 | mkdir 0755,$bkpdir if (! -d $bkpdir) ;
|
---|
| 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);
|
---|
| 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";
|
---|
| 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
|
---|
| 41 | while($tool = <PROLIANT>) {
|
---|
| 42 | next if ($tool =~ /^#/);
|
---|
| 43 | chomp($tool);
|
---|
| 44 | $tooldir = dirname($tool);
|
---|
| 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";
|
---|
| 51 | print TOOLS "$tool\n";
|
---|
| 52 | }
|
---|
| 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";
|
---|
| 57 | }
|
---|
| 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";
|
---|
| 62 | }
|
---|
| 63 | if ($tool =~ /\/hponcfg$/) {
|
---|
| 64 | $ret = system("$tool -w $bkpdir/hponcfg.dat");
|
---|
| 65 | print SCRIPT "$tool -r $bkpdir/hponcfg.dat)");
|
---|
| 66 | }
|
---|
| 67 | if ($ret != 0) {
|
---|
| 68 | print "$tool returned an error. Hardware support may not be complete\n";
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 | close(PROLIANT);
|
---|
| 72 | close(TOOLS);
|
---|
| 73 | close(SCRIPT);
|
---|
| 74 | } else {
|
---|
| 75 | print "No Hardware support for $productname\n";
|
---|
| 76 | print "Ask your manufacturer to contribute to the mindi project\n";
|
---|
| 77 | }
|
---|
| 78 | rmdir $bkpdir if (-d $bkpdir) ;
|
---|