source: branches/2.2.9/mindi/mindi-bkphw @ 2865

Last change on this file since 2865 was 2865, checked in by bruno, 8 years ago

r4224@localhost: bruno | 2011-08-23 03:10:08 +0200

  • Fix a small remaining pb with new comment support
  • Property svn:executable set to *
File size: 3.8 KB
Line 
1#!/usr/bin/perl -w
2#
3# $Id$
4#
5# Backup the hardware configuration on machine supporting it
6# (Bios configuration, Raid configuration, ...)
7#
8use strict;
9use File::Basename;
10
11# Handling Configuration files
12my $tool = "";
13my $tooldir = "";
14my $ret = 0;
15my $productname = undef;
16
17die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
18my $locbkpdir = "/bkphw";
19my $bkpdir = "$ARGV[0]$locbkpdir";
20die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
21my $confdir = "$ARGV[1]";
22
23die "You need dmidecode for Hardware support\n" if (! -x "/usr/sbin/dmidecode");
24
25mkdir $bkpdir,0755 if (! -d $bkpdir) ;
26open(SYSTEM,"/usr/sbin/dmidecode -s 'system-product-name' 2> /dev/null |") || die "You need /usr/sbin/dmidecode for mindi hardware support";
27while (<SYSTEM>) {
28    next if (/^#/);
29    $productname = $_;
30    chomp($productname);
31    }
32close(SYSTEM);
33
34die "WARNING: No product name found for Hardware support\n" if (not defined $productname);
35
36if ($productname =~ /proliant/i) {
37    print "Detected a $productname. Nice. Continue to support my job :-)\n";
38    print "Activating Proliant support for mindi\n";
39    open(PROLIANT,"$confdir/proliant.files") || die "Unable to open $confdir/proliant.files";
40    open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
41    open(SCRIPT,"> $bkpdir/../mindi-rsthw") || die "Unable to open $bkpdir/../mindi-rsthw";
42    print SCRIPT  << 'EOF';
43#!/bin/bash
44#
45# This script will restore potentially your HW configuration
46# on your system before partioning occurs
47# You may want to reboot after that step if you think that
48# resetting BIOS parameters to the value restored
49# may have an impact on you restoration process
50#
51# put dynamic libraries at an accessible place
52for l in /usr/local/lib/*; do
53    ln -sf $l /usr/lib
54done
55EOF
56    while($tool = <PROLIANT>) {
57        next if ($tool =~ /^#/);
58        chomp($tool);
59        $tooldir = dirname($tool);
60        if (! (-x $tool)) {
61            print "You could install the SmartStart Scripting toolkit tool $tool\nto benefit from mindi's enhanced hardware support\n";
62            print "Get it from http://www.hp.com/servers/sstoolkit\n";
63            next;
64        } else {
65            print "Found $tool, activating enhanced HP Proliant support in mindi\n";
66            print TOOLS "$tool\n";
67        }
68        if ($tool =~ /\/conrep$/) {
69            $ret = system("cd $tooldir ; $tool -s -f$bkpdir/conrep.dat");
70            print SCRIPT "(cd $tooldir ; $tool -l -f$locbkpdir/conrep.dat)\n";
71            print TOOLS "$tool.xml\n";
72        }
73        if ($tool =~ /\/.acuxebin$/) {
74            my $dir=basename($tool);
75            $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");
76            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";
77            print TOOLS "$tooldir/bld\n";
78        }
79        if ($tool =~ /\/hpacucli$/) {
80            my $dir=basename($tool);
81            $ret = system("export ACUXE_BIN_INSTALLATION_DIR=$dir ; export IM_CFGFILE_PATH=$dir ; export ACUXE_LOCK_FILES_DIR=$dir/locks ; $tool -c $bkpdir/hpacucli.dat");
82            print SCRIPT "export ACUXE_BIN_INSTALLATION_DIR=$dir ; export IM_CFGFILE_PATH=$dir ; export ACUXE_LOCK_FILES_DIR=$dir/locks ; $tool -i $locbkpdir/hpacucli.dat\n";
83            print TOOLS "$tooldir/bld\n";
84        }
85        if ($tool =~ /\/hponcfg$/) {
86            $ret = system("$tool -w $bkpdir/hponcfg.dat");
87            print SCRIPT "$tool -r $locbkpdir/hponcfg.dat\n";
88        }
89        if ($tool =~ /\.scexe$/) {
90            print "Found $tool, that firmware will be applied at restore time on your HP Proliant\n";
91            print SCRIPT "./$tool\n";
92        }
93        if ($ret != 0) {
94            print "$tool returned an error. Hardware support may not be complete\n";
95        }
96    }
97    close(PROLIANT);
98    close(TOOLS);
99    close(SCRIPT);
100} else {
101    print "WARNING: No Hardware support for $productname\n";
102    print "You may ask your manufacturer to contribute to the mindi project (harmless)\n";
103}
104rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.