source: MondoRescue/branches/3.0/mindi/mindi-bkphw@ 2940

Last change on this file since 2940 was 2940, checked in by Bruno Cornec, 12 years ago
  • Fix #582 by avoiding the use of the term WARNING and using now INFO and a hopefully improved msg
  • Property svn:executable set to *
File size: 4.3 KB
RevLine 
[1761]1#!/usr/bin/perl -w
2#
[1777]3# $Id$
4#
[1761]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;
[2863]14my $productname = undef;
[1761]15
16die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
[1911]17my $locbkpdir = "/bkphw";
[1913]18my $bkpdir = "$ARGV[0]$locbkpdir";
[1761]19die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
20my $confdir = "$ARGV[1]";
21
[1877]22die "You need dmidecode for Hardware support\n" if (! -x "/usr/sbin/dmidecode");
23
[1782]24mkdir $bkpdir,0755 if (! -d $bkpdir) ;
[1877]25open(SYSTEM,"/usr/sbin/dmidecode -s 'system-product-name' 2> /dev/null |") || die "You need /usr/sbin/dmidecode for mindi hardware support";
[2863]26while (<SYSTEM>) {
27 next if (/^#/);
[2865]28 $productname = $_;
[2863]29 chomp($productname);
30 }
[1761]31close(SYSTEM);
32
[2940]33die "INFO: No product name found for Hardware support\n" if (not defined $productname);
[1795]34
[1761]35if ($productname =~ /proliant/i) {
[1814]36 print "Detected a $productname. Nice. Continue to support my job :-)\n";
[2882]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
[1761]44 open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
[2882]45 # generate a script that will be launched at rstore time to perform the HW setup
[1761]46 open(SCRIPT,"> $bkpdir/../mindi-rsthw") || die "Unable to open $bkpdir/../mindi-rsthw";
[1835]47 print SCRIPT << 'EOF';
[1761]48#!/bin/bash
49#
[2882]50# Script generated by mindi
51#
[1761]52# This script will restore potentially your HW configuration
[2882]53# on your system before partioning occurs.
54#
[1761]55# You may want to reboot after that step if you think that
56# resetting BIOS parameters to the value restored
[2882]57# may have an impact on your restoration process or if
58# you want to benefit from any firmware update that could have happened.
[1761]59#
60EOF
61 while($tool = <PROLIANT>) {
[2882]62 my $hasfound = 0;
[1761]63 next if ($tool =~ /^#/);
64 chomp($tool);
[2882]65 # skip non-executable/exising binaries
[2700]66 if (! (-x $tool)) {
[1761]67 next;
68 } else {
[2882]69 print "Found $tool, activating enhanced HP ProLiant support in mindi\n";
[1761]70 print TOOLS "$tool\n";
71 }
72 if ($tool =~ /\/conrep$/) {
[2891]73 # From the package
74 if (! -f "/opt/hp/hp-scripting-tools/etc/conrep.xml") {
75 $ret = system("$tool -s -x /opt/hp/hp-scripting-tools/etc/conrep.xml -f$bkpdir/conrep.dat");
76 # From the SSSTK
77 } elsif (! -f "/usr/share/conrep/conrep.xml") {
78 $ret = system("$tool -s -x /usr/share/conrep/conrep.xml -f$bkpdir/conrep.dat");
[2882]79 } else {
[2891]80 next;
[2882]81 }
[2891]82 print SCRIPT "$tool -l -f$locbkpdir/conrep.dat\n";
83 print TOOLS "$tool.xml\n";
[1761]84 }
[2882]85 if ($tool =~ /\/hpacuscripting$/) {
86 $hasfound = 1;
[1814]87 my $dir=basename($tool);
[2882]88 # Just backup internal info for a DR
89 $ret = system("$tool -c $bkpdir/hpacuscripting.dat -internal");
90 # We could want to reset it before.
91 print SCRIPT "# $tool -reset -i $locbkpdir/hpacusripting.dat\n";
92 print SCRIPT "$tool -i $locbkpdir/hpacusripting.dat\n";
[1761]93 }
94 if ($tool =~ /\/hponcfg$/) {
[2882]95 $ret = system("$tool -a -w $bkpdir/hponcfg.dat");
96 print SCRIPT "$tool -f $locbkpdir/hponcfg.dat\n";
[1761]97 }
[1764]98 if ($tool =~ /\.scexe$/) {
[2882]99 print "Found $tool, that firmware will be applied at restore time on your HP ProLiant\n";
100 print SCRIPT "./$tool -s\n";
[1764]101 }
[2882]102 # Kept for compatibility with older version of tools
103 if (($tool =~ /\/hpacucli$/) && ($hasfound == 0)) {
104 my $dir=basename($tool);
105 $ret = system("$tool -c $bkpdir/hpacucli.dat");
106 print SCRIPT "$tool -i $locbkpdir/hpacucli.dat\n";
107 }
[1761]108 if ($ret != 0) {
109 print "$tool returned an error. Hardware support may not be complete\n";
110 }
111 }
112 close(PROLIANT);
113 close(TOOLS);
114 close(SCRIPT);
115} else {
[2940]116 print "INFO: No Hardware optimized support for your product $productname\n";
117 print "You may ask your manufacturer to contribute to the mindi project\nfor firmware Disaster Recovery support (harmless)\n";
[1761]118}
119rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.