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