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