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