source: MondoRescue/devel/mrmini/sbin/mindi-bkphw@ 2648

Last change on this file since 2648 was 2648, checked in by Bruno Cornec, 14 years ago

r3873@localhost: bruno | 2010-06-10 12:28:15 +0200

  • Big renaming in progress mindi => mrmini
  • Property svn:executable set to *
File size: 3.8 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;
10use MondoRescue::Inventory;
11use ProjectBuilder::Conf;
12
13# Handling Configuration files
14my $tool = "";
15my $tooldir = "";
16my $ret = 0;
17
18die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
19my $locbkpdir = "/bkphw";
20my $bkpdir = "$ARGV[0]$locbkpdir";
21die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
22my $confdir = "$ARGV[1]";
23
24my $conffile = "/etc/mondorescue/commands.conf";
25my $pbproj = "mondorescue";
26
27pb_conf_init($pbproj);
28pb_conf_add($conffile);
29
30my ($dmidecode) = pb_conf_get("dmidecode");
31die "You need a dmidecode entry in your configuration file $conffile\n" if (! defined $dmidecode->{$pbproj});
32die "You need dmidecode for Hardware support\n" if (! -x $dmidecode->{$pbproj});
33
34mkdir $bkpdir,0755 if (! -d $bkpdir) ;
35open(SYSTEM,"$dmidecode->{$pbproj} -s 'system-product-name' 2> /dev/null |") || die "You need a functional $dmidecode->{$pbproj} for mrmini hardware support";
36my $productname = <SYSTEM>;
37close(SYSTEM);
38
39die "ERROR: No product name found for Hardware support\n" if (not defined $productname);
40
41chomp($productname);
42if ($productname =~ /proliant/i) {
43 print "Detected a $productname. Nice. Continue to support my job :-)\n";
44 print "Activating Proliant support for mrmini\n";
45 open(PROLIANT,"$confdir/proliant.files") || die "Unable to open $confdir/proliant.files";
46 open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
47 open(SCRIPT,"> $bkpdir/../mrmini-rsthw") || die "Unable to open $bkpdir/../mrmini-rsthw";
48 print SCRIPT << 'EOF';
49#!/bin/bash
50#
51# This script will restore potentially your HW configuration
52# on your system before partioning occurs
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 you restoration process
56#
57# put dynamic libraries at an accessible place
58for l in /usr/local/lib/*; do
59 ln -sf $l /usr/lib
60done
61EOF
62 while($tool = <PROLIANT>) {
63 next if ($tool =~ /^#/);
64 chomp($tool);
65 $tooldir = dirname($tool);
66 if (! (-e $tool)) {
67 print "You should install the SmartStart Scripting toolkit tool $tool\nto benefit from mrmini's enhanced hardware support\n";
68 print "Get it from http://www.hp.com/servers/sstoolkit\n";
69 next;
70 } else {
71 print "Found $tool, activating enhanced HP Proliant support in mrmini\n";
72 print TOOLS "$tool\n";
73 }
74 if ($tool =~ /\/conrep$/) {
75 $ret = system("cd $tooldir ; $tool -s -f$bkpdir/conrep.dat");
76 print SCRIPT "(cd $tooldir ; $tool -l -f$locbkpdir/conrep.dat)\n";
77 print TOOLS "$tool.xml\n";
78 }
79 if ($tool =~ /\/.acuxebin$/) {
80 my $dir=basename($tool);
81 $ret = system("export ACUXE_BIN_INSTALLATION_DIR=$dir ; export IM_CFGFILE_PATH=$dir ; export ACUXE_LOCK_FILES_DIR=$dir/locks ; $tool -c $bkpdir/cpqacuxe.dat");
82 print SCRIPT "export ACUXE_BIN_INSTALLATION_DIR=$dir ; export IM_CFGFILE_PATH=$dir ; export ACUXE_LOCK_FILES_DIR=$dir/locks ; $tool -i $locbkpdir/cpqacuxe.dat\n";
83 print TOOLS "$tooldir/bld\n";
84 }
85 if ($tool =~ /\/hponcfg$/) {
86 $ret = system("$tool -w $bkpdir/hponcfg.dat");
87 print SCRIPT "$tool -r $locbkpdir/hponcfg.dat\n";
88 }
89 if ($tool =~ /\.scexe$/) {
90 print "Found $tool, that firmware will be applied at restore time on your HP Proliant\n";
91 print SCRIPT "./$tool\n";
92 }
93 if ($ret != 0) {
94 print "$tool returned an error. Hardware support may not be complete\n";
95 }
96 }
97 close(PROLIANT);
98 close(TOOLS);
99 close(SCRIPT);
100} else {
101 print "\nWARNING: No Hardware support for $productname. Not a big issue, just less features and risks ;-)\n";
102 print "You may ask your manufacturer to contribute to the mrmini project\n";
103}
104rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.