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

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

Grr again a fix for bkphw

File size: 2.7 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,"dmidecode -s 'system-product-name' |") || die "You need dmidecode for mindi hardware support";
23my $productname = <SYSTEM>;
24close(SYSTEM);
25
26chomp($productname);
27if ($productname =~ /proliant/i) {
28    print "Detected an HP Hardware. 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#
42EOF
43    while($tool = <PROLIANT>) {
44        next if ($tool =~ /^#/);
45        chomp($tool);
46        $tooldir = dirname($tool);
47        if (! (-e $tool)) {
48            print "You should install the SmartStart Scripting toolkit tool $tool\nto benefit from mindi's enhanced hardware support\n";
49            print "Get it from http://www.hp.com/servers/sstoolkit\n";
50            next;
51        } else {
52            print "Found $tool, activating enhanced HP Proliant support in mindi\n";
53            print TOOLS "$tool\n";
54        }
55        if ($tool =~ /\/conrep$/) {
56            $ret = system("cd $tooldir ; $tool -s -f$bkpdir/conrep.dat");
57            print SCRIPT "(cd $tooldir ; $tool -l -f$bkpdir/conrep.dat)\n";
58            print TOOLS "$tool.xml\n";
59        }
60        if ($tool =~ /\/cpqacuxe$/) {
61            $ret = system("$tool -c $bkpdir/cpqacuxe.dat");
62            print SCRIPT "$tool -i $bkpdir/cpqacuxe.dat\n";
63            print TOOLS "$tooldir/bld\n";
64        }
65        if ($tool =~ /\/hponcfg$/) {
66            $ret = system("$tool -w $bkpdir/hponcfg.dat");
67            print SCRIPT "$tool -r $bkpdir/hponcfg.dat\n";
68        }
69        if ($tool =~ /\.scexe$/) {
70            print SCRIPT "$tool\n";
71        }
72        if ($ret != 0) {
73            print "$tool returned an error. Hardware support may not be complete\n";
74        }
75    }
76    close(PROLIANT);
77    close(TOOLS);
78    close(SCRIPT);
79} else {
80    print "No Hardware support for $productname\n";
81    print "Ask your manufacturer to contribute to the mindi project\n";
82}
83rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.