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

Last change on this file since 3098 was 3094, checked in by Bruno Cornec, 11 years ago
  • Update ProLiant support with hp-rcu and hp-fm (Gen8 and following)
  • Property svn:executable set to *
File size: 4.4 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 "INFO: 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 SDR packages to benefit from mindi's enhanced ProLiant support\n";
39 print "Get them from http://downloads.linux.hp.com/SDR/\n";
40 open(PROLIANT,"$confdir/deplist.d/ProLiant.conf") || die "Unable to open $confdir/deplist.d/ProLiant.conf";
41 # generate a list of what need to be put on the backup media
42 open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
43 # generate a script that will be launched at rstore time to perform the HW setup
44 open(SCRIPT,"> $bkpdir/../mindi-rsthw") || die "Unable to open $bkpdir/../mindi-rsthw";
45 print SCRIPT << 'EOF';
46#!/bin/bash
47#
48# Script generated by mindi
49#
50# This script will restore potentially your HW configuration
51# on your system before partioning occurs.
52#
53# You may want to reboot after that step if you think that
54# resetting BIOS parameters to the value restored
55# may have an impact on your restoration process or if
56# you want to benefit from any firmware update that could have happened.
57#
58EOF
59 while($tool = <PROLIANT>) {
60 my $hasfound = 0;
61 next if ($tool =~ /^#/);
62 chomp($tool);
63 # skip non-executable/exising binaries
64 if (! (-x $tool)) {
65 next;
66 } else {
67 print "Found $tool, activating enhanced HP ProLiant support in mindi\n";
68 print TOOLS "$tool\n";
69 }
70 if ($tool =~ /\/conrep$/) {
71 my $xmlf = "/opt/hp/hp-scripting-tools/etc/conrep.xml";
72 # From the package
73 if (-f $xmlf) {
74 $ret = system("$tool -s -x $xmlf -f$bkpdir/conrep.dat");
75 # From the SSSTK
76 } else {
77 $xmlf = "/usr/share/conrep/conrep.xml";
78 if (-f $xmlf) {
79 $ret = system("$tool -s -x $xmlf -f$bkpdir/conrep.dat");
80 } else {
81 next;
82 }
83 }
84 print SCRIPT "$tool -l -f$locbkpdir/conrep.dat\n";
85 print TOOLS "$xmlf\n";
86 }
87 if ($tool =~ /\/hp-rcu$/) {
88 $ret = system("$tool -s -f$bkpdir/conrep.dat");
89 print SCRIPT "$tool -l -f$locbkpdir/conrep.dat\n";
90 }
91 if ($tool =~ /\/hpacuscripting$/) {
92 $hasfound = 1;
93 my $dir=basename($tool);
94 # Just backup internal info for a DR
95 $ret = system("$tool -c $bkpdir/hpacuscripting.dat -internal");
96 # We could want to reset it before.
97 print SCRIPT "# $tool -reset -i $locbkpdir/hpacusripting.dat\n";
98 print SCRIPT "$tool -i $locbkpdir/hpacusripting.dat\n";
99 }
100 if ($tool =~ /\/hponcfg$/) {
101 $ret = system("$tool -a -w $bkpdir/hponcfg.dat");
102 print SCRIPT "$tool -f $locbkpdir/hponcfg.dat\n";
103 }
104 if ($tool =~ /\.scexe$/) {
105 print "Found $tool, that firmware will be applied at restore time on your HP ProLiant\n";
106 print SCRIPT "./$tool -s\n";
107 }
108 if ($tool =~ /\/hp-fm/) {
109 print "Found $tool, firmware will be upgraded at restore time on your HP ProLiant\n";
110 print SCRIPT "./$tool upgrade\n";
111 }
112 # Kept for compatibility with older version of tools
113 if (($tool =~ /\/hpacucli$/) && ($hasfound == 0)) {
114 my $dir=basename($tool);
115 $ret = system("$tool -c $bkpdir/hpacucli.dat");
116 print SCRIPT "$tool -i $locbkpdir/hpacucli.dat\n";
117 }
118 if ($ret != 0) {
119 print "$tool returned an error. Hardware support may not be complete\n";
120 }
121 }
122 close(PROLIANT);
123 close(TOOLS);
124 close(SCRIPT);
125} else {
126 print "INFO: No Hardware optimized support for your product $productname\n";
127 print " You may ask your manufacturer to contribute to the mindi project\n for firmware Disaster Recovery support (harmless)\n";
128}
129rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.