[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 |
|
---|
[1877] | 21 | die "You need dmidecode for Hardware support\n" if (! -x "/usr/sbin/dmidecode");
|
---|
| 22 |
|
---|
[1782] | 23 | mkdir $bkpdir,0755 if (! -d $bkpdir) ;
|
---|
[1877] | 24 | open(SYSTEM,"/usr/sbin/dmidecode -s 'system-product-name' 2> /dev/null |") || die "You need /usr/sbin/dmidecode for mindi hardware support";
|
---|
[1761] | 25 | my $productname = <SYSTEM>;
|
---|
| 26 | close(SYSTEM);
|
---|
| 27 |
|
---|
[1844] | 28 | die "ERROR: No product name found for Hardware support\n" if (not defined $productname);
|
---|
[1795] | 29 |
|
---|
[1761] | 30 | chomp($productname);
|
---|
| 31 | if ($productname =~ /proliant/i) {
|
---|
[1814] | 32 | print "Detected a $productname. Nice. Continue to support my job :-)\n";
|
---|
[1761] | 33 | print "Activating Proliant support for mindi\n";
|
---|
| 34 | open(PROLIANT,"$confdir/proliant.files") || die "Unable to open $confdir/proliant.files";
|
---|
| 35 | open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
|
---|
| 36 | open(SCRIPT,"> $bkpdir/../mindi-rsthw") || die "Unable to open $bkpdir/../mindi-rsthw";
|
---|
[1835] | 37 | print SCRIPT << 'EOF';
|
---|
[1761] | 38 | #!/bin/bash
|
---|
| 39 | #
|
---|
| 40 | # This script will restore potentially your HW configuration
|
---|
| 41 | # on your system before partioning occurs
|
---|
| 42 | # You may want to reboot after that step if you think that
|
---|
| 43 | # resetting BIOS parameters to the value restored
|
---|
| 44 | # may have an impact on you restoration process
|
---|
| 45 | #
|
---|
[1834] | 46 | # put dynamic libraries at an accessible place
|
---|
| 47 | for l in /usr/local/lib/*; do
|
---|
| 48 | ln -sf $l /usr/lib
|
---|
| 49 | done
|
---|
[1761] | 50 | EOF
|
---|
| 51 | while($tool = <PROLIANT>) {
|
---|
| 52 | next if ($tool =~ /^#/);
|
---|
| 53 | chomp($tool);
|
---|
| 54 | $tooldir = dirname($tool);
|
---|
| 55 | if (! (-e $tool)) {
|
---|
| 56 | print "You should install the SmartStart Scripting toolkit tool $tool\nto benefit from mindi's enhanced hardware support\n";
|
---|
| 57 | print "Get it from http://www.hp.com/servers/sstoolkit\n";
|
---|
| 58 | next;
|
---|
| 59 | } else {
|
---|
| 60 | print "Found $tool, activating enhanced HP Proliant support in mindi\n";
|
---|
| 61 | print TOOLS "$tool\n";
|
---|
| 62 | }
|
---|
| 63 | if ($tool =~ /\/conrep$/) {
|
---|
[1777] | 64 | $ret = system("cd $tooldir ; $tool -s -f$bkpdir/conrep.dat");
|
---|
[1781] | 65 | print SCRIPT "(cd $tooldir ; $tool -l -f$bkpdir/conrep.dat)\n";
|
---|
[1761] | 66 | print TOOLS "$tool.xml\n";
|
---|
| 67 | }
|
---|
[1833] | 68 | if ($tool =~ /\/.acuxebin$/) {
|
---|
[1814] | 69 | my $dir=basename($tool);
|
---|
| 70 | $ret = system("export ACUXE_BIN_INSTALLATION_DIR=$dir ; export IM_CFGFILE_PATH=$dir ; export ACUXE_LOCK_FILES_DIR=$dir/locks ; $tool -c $bkpdir/cpqacuxe.dat");
|
---|
[1834] | 71 | print SCRIPT "export ACUXE_BIN_INSTALLATION_DIR=$dir ; export IM_CFGFILE_PATH=$dir ; export ACUXE_LOCK_FILES_DIR=$dir/locks ; $tool -i $bkpdir/cpqacuxe.dat\n";
|
---|
[1761] | 72 | print TOOLS "$tooldir/bld\n";
|
---|
| 73 | }
|
---|
| 74 | if ($tool =~ /\/hponcfg$/) {
|
---|
| 75 | $ret = system("$tool -w $bkpdir/hponcfg.dat");
|
---|
[1777] | 76 | print SCRIPT "$tool -r $bkpdir/hponcfg.dat\n";
|
---|
[1761] | 77 | }
|
---|
[1764] | 78 | if ($tool =~ /\.scexe$/) {
|
---|
[1880] | 79 | print "Found $tool, that firmware will be applied at restore time on your HP Proliant\n";
|
---|
[1781] | 80 | print SCRIPT "$tool\n";
|
---|
[1764] | 81 | }
|
---|
[1761] | 82 | if ($ret != 0) {
|
---|
| 83 | print "$tool returned an error. Hardware support may not be complete\n";
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 | close(PROLIANT);
|
---|
| 87 | close(TOOLS);
|
---|
| 88 | close(SCRIPT);
|
---|
| 89 | } else {
|
---|
[1844] | 90 | print "WARNING: No Hardware support for $productname\n";
|
---|
[1784] | 91 | print "You may ask your manufacturer to contribute to the mindi project\n";
|
---|
[1761] | 92 | }
|
---|
| 93 | rmdir $bkpdir if (-d $bkpdir) ;
|
---|