source: MondoRescue/branches/2.2.9/mindi/mindi-bkphw@ 2865

Last change on this file since 2865 was 2865, checked in by Bruno Cornec, 13 years ago

r4224@localhost: bruno | 2011-08-23 03:10:08 +0200

  • Fix a small remaining pb with new comment support
  • Property svn:executable set to *
File size: 3.8 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 $tooldir = "";
14my $ret = 0;
[2863]15my $productname = undef;
[1761]16
17die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
[1911]18my $locbkpdir = "/bkphw";
[1913]19my $bkpdir = "$ARGV[0]$locbkpdir";
[1761]20die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
21my $confdir = "$ARGV[1]";
22
[1877]23die "You need dmidecode for Hardware support\n" if (! -x "/usr/sbin/dmidecode");
24
[1782]25mkdir $bkpdir,0755 if (! -d $bkpdir) ;
[1877]26open(SYSTEM,"/usr/sbin/dmidecode -s 'system-product-name' 2> /dev/null |") || die "You need /usr/sbin/dmidecode for mindi hardware support";
[2863]27while (<SYSTEM>) {
28 next if (/^#/);
[2865]29 $productname = $_;
[2863]30 chomp($productname);
31 }
[1761]32close(SYSTEM);
33
[2863]34die "WARNING: No product name found for Hardware support\n" if (not defined $productname);
[1795]35
[1761]36if ($productname =~ /proliant/i) {
[1814]37 print "Detected a $productname. Nice. Continue to support my job :-)\n";
[1761]38 print "Activating Proliant support for mindi\n";
39 open(PROLIANT,"$confdir/proliant.files") || die "Unable to open $confdir/proliant.files";
40 open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
41 open(SCRIPT,"> $bkpdir/../mindi-rsthw") || die "Unable to open $bkpdir/../mindi-rsthw";
[1835]42 print SCRIPT << 'EOF';
[1761]43#!/bin/bash
44#
45# This script will restore potentially your HW configuration
46# on your system before partioning occurs
47# You may want to reboot after that step if you think that
48# resetting BIOS parameters to the value restored
49# may have an impact on you restoration process
50#
[1834]51# put dynamic libraries at an accessible place
52for l in /usr/local/lib/*; do
53 ln -sf $l /usr/lib
54done
[1761]55EOF
56 while($tool = <PROLIANT>) {
57 next if ($tool =~ /^#/);
58 chomp($tool);
59 $tooldir = dirname($tool);
[2700]60 if (! (-x $tool)) {
[2709]61 print "You could install the SmartStart Scripting toolkit tool $tool\nto benefit from mindi's enhanced hardware support\n";
[1761]62 print "Get it from http://www.hp.com/servers/sstoolkit\n";
63 next;
64 } else {
65 print "Found $tool, activating enhanced HP Proliant support in mindi\n";
66 print TOOLS "$tool\n";
67 }
68 if ($tool =~ /\/conrep$/) {
[1777]69 $ret = system("cd $tooldir ; $tool -s -f$bkpdir/conrep.dat");
[1911]70 print SCRIPT "(cd $tooldir ; $tool -l -f$locbkpdir/conrep.dat)\n";
[1761]71 print TOOLS "$tool.xml\n";
72 }
[1833]73 if ($tool =~ /\/.acuxebin$/) {
[1814]74 my $dir=basename($tool);
75 $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");
[1911]76 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";
[1761]77 print TOOLS "$tooldir/bld\n";
78 }
[2700]79 if ($tool =~ /\/hpacucli$/) {
[2695]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/hpacucli.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/hpacucli.dat\n";
83 print TOOLS "$tooldir/bld\n";
84 }
[1761]85 if ($tool =~ /\/hponcfg$/) {
86 $ret = system("$tool -w $bkpdir/hponcfg.dat");
[1911]87 print SCRIPT "$tool -r $locbkpdir/hponcfg.dat\n";
[1761]88 }
[1764]89 if ($tool =~ /\.scexe$/) {
[1880]90 print "Found $tool, that firmware will be applied at restore time on your HP Proliant\n";
[1911]91 print SCRIPT "./$tool\n";
[1764]92 }
[1761]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 {
[1844]101 print "WARNING: No Hardware support for $productname\n";
[2863]102 print "You may ask your manufacturer to contribute to the mindi project (harmless)\n";
[1761]103}
104rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.