source: MondoRescue/branches/2.2.9/mindi/mindi-bkphw@ 2882

Last change on this file since 2882 was 2882, checked in by Bruno Cornec, 13 years ago
  • Add compatibility with the latest SSSTK + PSP content for HP ProLiant + branding homogeneous now. We only take conrep out of the SSSTK pending a package availability. Using hpacuscripting now. Review of parameters called following test made.
  • Property svn:executable set to *
File size: 4.0 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 $ret = 0;
14my $productname = undef;
15
16die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
17my $locbkpdir = "/bkphw";
18my $bkpdir = "$ARGV[0]$locbkpdir";
19die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
20my $confdir = "$ARGV[1]";
21
22die "You need dmidecode for Hardware support\n" if (! -x "/usr/sbin/dmidecode");
23
24mkdir $bkpdir,0755 if (! -d $bkpdir) ;
25open(SYSTEM,"/usr/sbin/dmidecode -s 'system-product-name' 2> /dev/null |") || die "You need /usr/sbin/dmidecode for mindi hardware support";
26while (<SYSTEM>) {
27 next if (/^#/);
28 $productname = $_;
29 chomp($productname);
30 }
31close(SYSTEM);
32
33die "WARNING: No product name found for Hardware support\n" if (not defined $productname);
34
35if ($productname =~ /proliant/i) {
36 print "Detected a $productname. Nice. Continue to support my job :-)\n";
37 print "Activating ProLiant support for mindi\n";
38 print "You can install the SmartStart Scripting toolkit tool $tool\nto benefit from mindi's enhanced ProLiant support\n";
39 print "Get it from http://www.hp.com/servers/sstoolkit\n";
40 print "And use the SDR to get all other HP ProLiant packages\n";
41 print "Get it from http://downloads.linux.hp.com/SDR/downloads/ProLiantSupportPack/\n";
42 open(PROLIANT,"$confdir/deplist.d/ProLiant.conf") || die "Unable to open $confdir/deplist.d/ProLiant.conf";
43 # generate a list of what need to be put on the backup media
44 open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
45 # generate a script that will be launched at rstore time to perform the HW setup
46 open(SCRIPT,"> $bkpdir/../mindi-rsthw") || die "Unable to open $bkpdir/../mindi-rsthw";
47 print SCRIPT << 'EOF';
48#!/bin/bash
49#
50# Script generated by mindi
51#
52# This script will restore potentially your HW configuration
53# on your system before partioning occurs.
54#
55# You may want to reboot after that step if you think that
56# resetting BIOS parameters to the value restored
57# may have an impact on your restoration process or if
58# you want to benefit from any firmware update that could have happened.
59#
60EOF
61 while($tool = <PROLIANT>) {
62 my $hasfound = 0;
63 next if ($tool =~ /^#/);
64 chomp($tool);
65 # skip non-executable/exising binaries
66 if (! (-x $tool)) {
67 next;
68 } else {
69 print "Found $tool, activating enhanced HP ProLiant support in mindi\n";
70 print TOOLS "$tool\n";
71 }
72 if ($tool =~ /\/conrep$/) {
73 if (! -f "/usr/share/conrep/conrep.xml") {
74 } else {
75 $ret = system("$tool -s -x /usr/share/conrep/conrep.xml -f$bkpdir/conrep.dat");
76 print SCRIPT "($tool -l -f$locbkpdir/conrep.dat)\n";
77 print TOOLS "$tool.xml\n";
78 }
79 }
80 if ($tool =~ /\/hpacuscripting$/) {
81 $hasfound = 1;
82 my $dir=basename($tool);
83 # Just backup internal info for a DR
84 $ret = system("$tool -c $bkpdir/hpacuscripting.dat -internal");
85 # We could want to reset it before.
86 print SCRIPT "# $tool -reset -i $locbkpdir/hpacusripting.dat\n";
87 print SCRIPT "$tool -i $locbkpdir/hpacusripting.dat\n";
88 }
89 if ($tool =~ /\/hponcfg$/) {
90 $ret = system("$tool -a -w $bkpdir/hponcfg.dat");
91 print SCRIPT "$tool -f $locbkpdir/hponcfg.dat\n";
92 }
93 if ($tool =~ /\.scexe$/) {
94 print "Found $tool, that firmware will be applied at restore time on your HP ProLiant\n";
95 print SCRIPT "./$tool -s\n";
96 }
97 # Kept for compatibility with older version of tools
98 if (($tool =~ /\/hpacucli$/) && ($hasfound == 0)) {
99 my $dir=basename($tool);
100 $ret = system("$tool -c $bkpdir/hpacucli.dat");
101 print SCRIPT "$tool -i $locbkpdir/hpacucli.dat\n";
102 }
103 if ($ret != 0) {
104 print "$tool returned an error. Hardware support may not be complete\n";
105 }
106 }
107 close(PROLIANT);
108 close(TOOLS);
109 close(SCRIPT);
110} else {
111 print "WARNING: No Hardware support for $productname\n";
112 print "You may ask your manufacturer to contribute to the mindi project (harmless)\n";
113}
114rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.