source: MondoRescue/branches/3.2/mindi/mindi-bkphw@ 3262

Last change on this file since 3262 was 3143, checked in by Bruno Cornec, 11 years ago

r5349@localhost: bruno | 2013-06-14 01:23:53 +0200

  • Adds pod content to the perl scripts used, and generate man pages frmo it as part of the install process. This also fixes rpmlint and deblint issues
  • Property svn:executable set to *
File size: 6.1 KB
Line 
1#!/usr/bin/perl -w
2#
3# $Id$
4# Copyright B. Cornec 2005-2013
5# Provided under the GPL v2
6#
7# Backup the hardware configuration on machine supporting it
8# (Bios configuration, Raid configuration, ...)
9#
10use strict;
11use File::Basename;
12
13=pod
14
15=head1 NAME
16
17mindi-bkphw keeps track of your hardware configuration (BIOS, Raid, Management board, ...)
18
19=head1 DESCRIPTION
20
21mindi-bkphw keeps track of your hardware configuration by calling the tool provided by IHV (Independant Hardware Vendor) in order to store the configuration of the system BIOS, the RAID controller or the onboard management card if any of those is present.
22
23For the moment, this is only working for HP ProLiant servers, as HP provides all these tools in a convenient way to perform these actions. Other manufacturer can provide patches or relevant info in order to be supported as well here.
24
25=head1 SYNOPSIS
26
27mindi-bkphw /path/to/cache-dir /path/to/conf-dir
28
29=head1 ARGUMENTS
30
31=over 4
32
33=item B</path/to/cache-dir>
34
35This is the directory where the generated files will be stored.
36
37=item B</path/to/conf-dir>
38
39This is the directory where the configuration file describing the tools needed to backup hardware information is stored. Generaly /etc/mindi. It should contain a deplist.d subdirectory, and for now only the ProLiant.conf file is used in it.
40
41=back
42
43=head1 WEB SITES
44
45The main Web site of the project is available at L<http://www.mondorescue.org>. Bug reports should be filled using the trac instance of the project at L<http://trac.mondorescue.org/>.
46
47=head1 USER MAILING LIST
48
49For community exchanges around MondoRescue please use the list L<http://sourceforge.net/mailarchive/forum.php?forum_name=mondo-devel>
50
51=head1 AUTHORS
52
53The MondoRescue team lead by Bruno Cornec L<mailto:bruno@mondorescue.org>.
54
55=head1 COPYRIGHT
56
57MondoRescue is distributed under the GPL v2.0 license or later,
58described in the file C<COPYING> included with the distribution.
59
60=cut
61
62
63# Handling Configuration files
64my $tool = "";
65my $ret = 0;
66my $productname = undef;
67
68die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
69my $locbkpdir = "/bkphw";
70my $bkpdir = "$ARGV[0]$locbkpdir";
71die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
72my $confdir = "$ARGV[1]";
73
74die "You need dmidecode for Hardware support\n" if (! -x "/usr/sbin/dmidecode");
75
76mkdir $bkpdir,0755 if (! -d $bkpdir) ;
77open(SYSTEM,"/usr/sbin/dmidecode -s 'system-product-name' 2> /dev/null |") || die "You need /usr/sbin/dmidecode for mindi hardware support";
78while (<SYSTEM>) {
79 next if (/^#/);
80 $productname = $_;
81 chomp($productname);
82 }
83close(SYSTEM);
84
85die "INFO: No product name found for Hardware support\n" if (not defined $productname);
86
87if ($productname =~ /proliant/i) {
88 print "Detected a $productname. Nice. Continue to support my job :-)\n";
89 print "Activating ProLiant support for mindi\n";
90 print "You can install SDR packages to benefit from mindi's enhanced ProLiant support\n";
91 print "Get them from http://downloads.linux.hp.com/SDR/\n";
92 open(PROLIANT,"$confdir/deplist.d/ProLiant.conf") || die "Unable to open $confdir/deplist.d/ProLiant.conf";
93 # generate a list of what need to be put on the backup media
94 open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
95 # generate a script that will be launched at rstore time to perform the HW setup
96 open(SCRIPT,"> $bkpdir/../mindi-rsthw") || die "Unable to open $bkpdir/../mindi-rsthw";
97 print SCRIPT << 'EOF';
98#!/bin/bash
99#
100# Script generated by mindi
101#
102# This script will restore potentially your HW configuration
103# on your system before partioning occurs.
104#
105# You may want to reboot after that step if you think that
106# resetting BIOS parameters to the value restored
107# may have an impact on your restoration process or if
108# you want to benefit from any firmware update that could have happened.
109#
110EOF
111 while($tool = <PROLIANT>) {
112 my $hasfound = 0;
113 next if ($tool =~ /^#/);
114 chomp($tool);
115 # skip non-executable/exising binaries
116 if (! (-x $tool)) {
117 next;
118 } else {
119 print "Found $tool, activating enhanced HP ProLiant support in mindi\n";
120 print TOOLS "$tool\n";
121 }
122 if ($tool =~ /\/conrep$/) {
123 my $xmlf = "/opt/hp/hp-scripting-tools/etc/conrep.xml";
124 # From the package
125 if (-f $xmlf) {
126 $ret = system("$tool -s -x $xmlf -f$bkpdir/conrep.dat");
127 # From the SSSTK
128 } else {
129 $xmlf = "/usr/share/conrep/conrep.xml";
130 if (-f $xmlf) {
131 $ret = system("$tool -s -x $xmlf -f$bkpdir/conrep.dat");
132 } else {
133 next;
134 }
135 }
136 print SCRIPT "$tool -l -f$locbkpdir/conrep.dat\n";
137 print TOOLS "$xmlf\n";
138 }
139 if ($tool =~ /\/hp-rcu$/) {
140 $ret = system("$tool -s -f$bkpdir/conrep.dat");
141 print SCRIPT "$tool -l -f$locbkpdir/conrep.dat\n";
142 }
143 if ($tool =~ /\/hpacuscripting$/) {
144 $hasfound = 1;
145 my $dir=basename($tool);
146 # Just backup internal info for a DR
147 $ret = system("$tool -c $bkpdir/hpacuscripting.dat -internal");
148 # We could want to reset it before.
149 print SCRIPT "# $tool -reset -i $locbkpdir/hpacusripting.dat\n";
150 print SCRIPT "$tool -i $locbkpdir/hpacusripting.dat\n";
151 }
152 if ($tool =~ /\/hponcfg$/) {
153 $ret = system("$tool -a -w $bkpdir/hponcfg.dat");
154 print SCRIPT "$tool -f $locbkpdir/hponcfg.dat\n";
155 }
156 if ($tool =~ /\.scexe$/) {
157 print "Found $tool, that firmware will be applied at restore time on your HP ProLiant\n";
158 print SCRIPT "./$tool -s\n";
159 }
160 if ($tool =~ /\/hp-fm/) {
161 print "Found $tool, firmware will be upgraded at restore time on your HP ProLiant\n";
162 print SCRIPT "./$tool upgrade\n";
163 }
164 # Kept for compatibility with older version of tools
165 if (($tool =~ /\/hpacucli$/) && ($hasfound == 0)) {
166 my $dir=basename($tool);
167 $ret = system("$tool -c $bkpdir/hpacucli.dat");
168 print SCRIPT "$tool -i $locbkpdir/hpacucli.dat\n";
169 }
170 if ($ret != 0) {
171 print "$tool returned an error. Hardware support may not be complete\n";
172 }
173 }
174 close(PROLIANT);
175 close(TOOLS);
176 close(SCRIPT);
177} else {
178 print "INFO: No Hardware optimized support for your product $productname\n";
179 print " You may ask your manufacturer to contribute to the mindi project\n for firmware Disaster Recovery support (harmless)\n";
180}
181rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.