[925] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
[1842] | 3 | # $Id$
|
---|
| 4 | #
|
---|
[925] | 5 | # Backup the hardware configuration on machine supporting it
|
---|
| 6 | # (Bios configuration, Raid configuration, ...)
|
---|
| 7 | #
|
---|
[1280] | 8 | use strict;
|
---|
[1469] | 9 | use File::Basename;
|
---|
[925] | 10 |
|
---|
[1280] | 11 | # Handling Configuration files
|
---|
[1770] | 12 | die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
|
---|
| 13 | my $bkpdir = "$ARGV[0]/bkphw";
|
---|
| 14 | die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
|
---|
| 15 | my $confdir = "$ARGV[1]";
|
---|
| 16 |
|
---|
| 17 | mkdir $bkpdir,0755 if (! -d $bkpdir) ;
|
---|
[1842] | 18 | open(SYSTEM,"/usr/sbin/dmidecode -s 'system-product-name' |") || die "You need /usr/sbin/dmidecode for mindi hardware support";
|
---|
[1280] | 19 | my $productname = <SYSTEM>;
|
---|
| 20 | close(SYSTEM);
|
---|
| 21 |
|
---|
[1842] | 22 | die "No product name found for Hardware support\n" if (not defined $productname);
|
---|
| 23 |
|
---|
[1280] | 24 | chomp($productname);
|
---|
[1467] | 25 | if ($productname =~ /proliant/i) {
|
---|
[1842] | 26 | print "Detected a $productname. Nice. Continue to support my job :-)\n";
|
---|
[1467] | 27 | print "Activating Proliant support for mindi\n";
|
---|
[1770] | 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";
|
---|
[1842] | 31 | print SCRIPT << 'EOF';
|
---|
[1770] | 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 | #
|
---|
[1842] | 40 | # put dynamic libraries at an accessible place
|
---|
| 41 | for l in /usr/local/lib/*; do
|
---|
| 42 | ln -sf $l /usr/lib
|
---|
| 43 | done
|
---|
[1770] | 44 | EOF
|
---|
[1467] | 45 | while($tool = <PROLIANT>) {
|
---|
| 46 | next if ($tool =~ /^#/);
|
---|
| 47 | chomp($tool);
|
---|
[1469] | 48 | $tooldir = dirname($tool);
|
---|
[1467] | 49 | if (! (-e $tool)) {
|
---|
| 50 | print "You should install the SmartStart Scripting toolkit tool $tool\nto benefit from mindi's enhanced hardware support\n";
|
---|
| 51 | print "Get it from http://www.hp.com/servers/sstoolkit\n";
|
---|
| 52 | next;
|
---|
| 53 | } else {
|
---|
| 54 | print "Found $tool, activating enhanced HP Proliant support in mindi\n";
|
---|
[1770] | 55 | print TOOLS "$tool\n";
|
---|
[1280] | 56 | }
|
---|
[1770] | 57 | if ($tool =~ /\/conrep$/) {
|
---|
[1842] | 58 | $ret = system("cd $tooldir ; $tool -s -f$bkpdir/conrep.dat");
|
---|
| 59 | print SCRIPT "(cd $tooldir ; $tool -l -f$bkpdir/conrep.dat)\n";
|
---|
[1770] | 60 | print TOOLS "$tool.xml\n";
|
---|
[1467] | 61 | }
|
---|
[1842] | 62 | if ($tool =~ /\/.acuxebin$/) {
|
---|
| 63 | my $dir=basename($tool);
|
---|
| 64 | $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");
|
---|
| 65 | 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";
|
---|
[1770] | 66 | print TOOLS "$tooldir/bld\n";
|
---|
[1467] | 67 | }
|
---|
[1770] | 68 | if ($tool =~ /\/hponcfg$/) {
|
---|
| 69 | $ret = system("$tool -w $bkpdir/hponcfg.dat");
|
---|
[1842] | 70 | print SCRIPT "$tool -r $bkpdir/hponcfg.dat\n";
|
---|
[1467] | 71 | }
|
---|
[1770] | 72 | if ($tool =~ /\.scexe$/) {
|
---|
[1842] | 73 | print SCRIPT "$tool\n";
|
---|
[1770] | 74 | }
|
---|
[1467] | 75 | if ($ret != 0) {
|
---|
| 76 | print "$tool returned an error. Hardware support may not be complete\n";
|
---|
| 77 | }
|
---|
[1280] | 78 | }
|
---|
[1770] | 79 | close(PROLIANT);
|
---|
| 80 | close(TOOLS);
|
---|
| 81 | close(SCRIPT);
|
---|
[1280] | 82 | } else {
|
---|
| 83 | print "No Hardware support for $productname\n";
|
---|
[1842] | 84 | print "You may ask your manufacturer to contribute to the mindi project\n";
|
---|
[1280] | 85 | }
|
---|
[1770] | 86 | rmdir $bkpdir if (-d $bkpdir) ;
|
---|