source: branches/2.2.5/mindi/mindi-bkphw @ 1795

Last change on this file since 1795 was 1795, checked in by bruno, 12 years ago

Avoids continuing hw support if no product name found

File size: 2.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;
15
16die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
17my $bkpdir = "$ARGV[0]/bkphw";
18die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
19my $confdir = "$ARGV[1]";
20
21mkdir $bkpdir,0755 if (! -d $bkpdir) ;
22open(SYSTEM,"/usr/sbin/dmidecode -s 'system-product-name' |") || die "You need /usr/sbin/dmidecode for mindi hardware support";
23my $productname = <SYSTEM>;
24close(SYSTEM);
25
26die "No product name found for Hardware support\n" if (not defined $productname);
27
28chomp($productname);
29if ($productname =~ /proliant/i) {
30    print "Detected an HP Proliant Server. Nice. Continue to support my job :-)\n";
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";
35    print SCRIPT  << "EOF";
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#
44EOF
45    while($tool = <PROLIANT>) {
46        next if ($tool =~ /^#/);
47        chomp($tool);
48        $tooldir = dirname($tool);
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";
55            print TOOLS "$tool\n";
56        }
57        if ($tool =~ /\/conrep$/) {
58            $ret = system("cd $tooldir ; $tool -s -f$bkpdir/conrep.dat");
59            print SCRIPT "(cd $tooldir ; $tool -l -f$bkpdir/conrep.dat)\n";
60            print TOOLS "$tool.xml\n";
61        }
62        if ($tool =~ /\/cpqacuxe$/) {
63            $ret = system("$tool -c $bkpdir/cpqacuxe.dat");
64            print SCRIPT "$tool -i $bkpdir/cpqacuxe.dat\n";
65            print TOOLS "$tooldir/bld\n";
66        }
67        if ($tool =~ /\/hponcfg$/) {
68            $ret = system("$tool -w $bkpdir/hponcfg.dat");
69            print SCRIPT "$tool -r $bkpdir/hponcfg.dat\n";
70        }
71        if ($tool =~ /\.scexe$/) {
72            print SCRIPT "$tool\n";
73        }
74        if ($ret != 0) {
75            print "$tool returned an error. Hardware support may not be complete\n";
76        }
77    }
78    close(PROLIANT);
79    close(TOOLS);
80    close(SCRIPT);
81} else {
82    print "No Hardware support for $productname\n";
83    print "You may ask your manufacturer to contribute to the mindi project\n";
84}
85rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.