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

Last change on this file since 3070 was 2995, checked in by Bruno Cornec, 12 years ago
  • Solve #610 by adding a --nolog option to mindi, which needs to be the first one, and used in analyze-my-lvm with a rdirection of errors to /dev/null.
  • Improve udev.conf file for Mageia by adding some required files
  • Improve logs generation in mindi by removing remaining oddities
  • Property svn:executable set to *
File size: 4.3 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 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 # 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");
79 } else {
80 next;
81 }
82 print SCRIPT "$tool -l -f$locbkpdir/conrep.dat\n";
83 print TOOLS "$tool.xml\n";
84 }
85 if ($tool =~ /\/hpacuscripting$/) {
86 $hasfound = 1;
87 my $dir=basename($tool);
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";
93 }
94 if ($tool =~ /\/hponcfg$/) {
95 $ret = system("$tool -a -w $bkpdir/hponcfg.dat");
96 print SCRIPT "$tool -f $locbkpdir/hponcfg.dat\n";
97 }
98 if ($tool =~ /\.scexe$/) {
99 print "Found $tool, that firmware will be applied at restore time on your HP ProLiant\n";
100 print SCRIPT "./$tool -s\n";
101 }
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 }
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 {
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\n for firmware Disaster Recovery support (harmless)\n";
118}
119rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.