source: branches/stable/mindi/mindi-bkphw @ 1924

Last change on this file since 1924 was 1924, checked in by bruno, 11 years ago

svn merge -r 1902:1923 $SVN_M/branches/2.2.6

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