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

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

merge -r 1842:1889 2.2.5

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