1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # $Id$
|
---|
4 | #
|
---|
5 | # Backup the hardware configuration on machine supporting it
|
---|
6 | # (Bios configuration, Raid configuration, ...)
|
---|
7 | #
|
---|
8 | use strict;
|
---|
9 | use File::Basename;
|
---|
10 |
|
---|
11 | # Handling Configuration files
|
---|
12 | my $tool = "";
|
---|
13 | my $tooldir = "";
|
---|
14 | my $ret = 0;
|
---|
15 |
|
---|
16 | die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
|
---|
17 | my $bkpdir = "$ARGV[0]/bkphw";
|
---|
18 | die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
|
---|
19 | my $confdir = "$ARGV[1]";
|
---|
20 |
|
---|
21 | mkdir $bkpdir,0755 if (! -d $bkpdir) ;
|
---|
22 | open(SYSTEM,"/usr/sbin/dmidecode -s 'system-product-name' |") || die "You need /usr/sbin/dmidecode for mindi hardware support";
|
---|
23 | my $productname = <SYSTEM>;
|
---|
24 | close(SYSTEM);
|
---|
25 |
|
---|
26 | die "No product name found for Hardware support\n" if (not defined $productname);
|
---|
27 |
|
---|
28 | chomp($productname);
|
---|
29 | if ($productname =~ /proliant/i) {
|
---|
30 | print "Detected a $productname. 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 | #
|
---|
44 | # put dynamic libraries at an accessible place
|
---|
45 | for l in /usr/local/lib/*; do
|
---|
46 | ln -sf $l /usr/lib
|
---|
47 | done
|
---|
48 | EOF
|
---|
49 | while($tool = <PROLIANT>) {
|
---|
50 | next if ($tool =~ /^#/);
|
---|
51 | chomp($tool);
|
---|
52 | $tooldir = dirname($tool);
|
---|
53 | if (! (-e $tool)) {
|
---|
54 | print "You should install the SmartStart Scripting toolkit tool $tool\nto benefit from mindi's enhanced hardware support\n";
|
---|
55 | print "Get it from http://www.hp.com/servers/sstoolkit\n";
|
---|
56 | next;
|
---|
57 | } else {
|
---|
58 | print "Found $tool, activating enhanced HP Proliant support in mindi\n";
|
---|
59 | print TOOLS "$tool\n";
|
---|
60 | }
|
---|
61 | if ($tool =~ /\/conrep$/) {
|
---|
62 | $ret = system("cd $tooldir ; $tool -s -f$bkpdir/conrep.dat");
|
---|
63 | print SCRIPT "(cd $tooldir ; $tool -l -f$bkpdir/conrep.dat)\n";
|
---|
64 | print TOOLS "$tool.xml\n";
|
---|
65 | }
|
---|
66 | if ($tool =~ /\/.acuxebin$/) {
|
---|
67 | my $dir=basename($tool);
|
---|
68 | $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");
|
---|
69 | 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";
|
---|
70 | print TOOLS "$tooldir/bld\n";
|
---|
71 | }
|
---|
72 | if ($tool =~ /\/hponcfg$/) {
|
---|
73 | $ret = system("$tool -w $bkpdir/hponcfg.dat");
|
---|
74 | print SCRIPT "$tool -r $bkpdir/hponcfg.dat\n";
|
---|
75 | }
|
---|
76 | if ($tool =~ /\.scexe$/) {
|
---|
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 "No Hardware support for $productname\n";
|
---|
88 | print "You may ask your manufacturer to contribute to the mindi project\n";
|
---|
89 | }
|
---|
90 | rmdir $bkpdir if (-d $bkpdir) ;
|
---|