source: MondoRescue/branches/stable/mindi/mindi-bkphw@ 1924

Last change on this file since 1924 was 1924, checked in by Bruno Cornec, 16 years ago

svn merge -r 1902:1923 $SVN_M/branches/2.2.6

File size: 3.3 KB
RevLine 
[925]1#!/usr/bin/perl -w
2#
[1842]3# $Id$
4#
[925]5# Backup the hardware configuration on machine supporting it
6# (Bios configuration, Raid configuration, ...)
7#
[1280]8use strict;
[1469]9use File::Basename;
[925]10
[1280]11# Handling Configuration files
[1770]12die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
[1924]13my $locbkpdir = "/bkphw";
14my $bkpdir = "$ARGV[0]$locbkpdir";
[1770]15die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
16my $confdir = "$ARGV[1]";
17
[1903]18die "You need dmidecode for Hardware support\n" if (! -x "/usr/sbin/dmidecode");
19
[1770]20mkdir $bkpdir,0755 if (! -d $bkpdir) ;
[1903]21open(SYSTEM,"/usr/sbin/dmidecode -s 'system-product-name' 2> /dev/null |") || die "You need /usr/sbin/dmidecode for mindi hardware support";
[1280]22my $productname = <SYSTEM>;
23close(SYSTEM);
24
[1903]25die "ERROR: No product name found for Hardware support\n" if (not defined $productname);
[1842]26
[1280]27chomp($productname);
[1467]28if ($productname =~ /proliant/i) {
[1842]29 print "Detected a $productname. Nice. Continue to support my job :-)\n";
[1467]30 print "Activating Proliant support for mindi\n";
[1770]31 open(PROLIANT,"$confdir/proliant.files") || die "Unable to open $confdir/proliant.files";
32 open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
33 open(SCRIPT,"> $bkpdir/../mindi-rsthw") || die "Unable to open $bkpdir/../mindi-rsthw";
[1842]34 print SCRIPT << 'EOF';
[1770]35#!/bin/bash
36#
37# This script will restore potentially your HW configuration
38# on your system before partioning occurs
39# You may want to reboot after that step if you think that
40# resetting BIOS parameters to the value restored
41# may have an impact on you restoration process
42#
[1842]43# put dynamic libraries at an accessible place
44for l in /usr/local/lib/*; do
45 ln -sf $l /usr/lib
46done
[1770]47EOF
[1467]48 while($tool = <PROLIANT>) {
49 next if ($tool =~ /^#/);
50 chomp($tool);
[1469]51 $tooldir = dirname($tool);
[1467]52 if (! (-e $tool)) {
53 print "You should install the SmartStart Scripting toolkit tool $tool\nto benefit from mindi's enhanced hardware support\n";
54 print "Get it from http://www.hp.com/servers/sstoolkit\n";
55 next;
56 } else {
57 print "Found $tool, activating enhanced HP Proliant support in mindi\n";
[1770]58 print TOOLS "$tool\n";
[1280]59 }
[1770]60 if ($tool =~ /\/conrep$/) {
[1842]61 $ret = system("cd $tooldir ; $tool -s -f$bkpdir/conrep.dat");
[1924]62 print SCRIPT "(cd $tooldir ; $tool -l -f$locbkpdir/conrep.dat)\n";
[1770]63 print TOOLS "$tool.xml\n";
[1467]64 }
[1842]65 if ($tool =~ /\/.acuxebin$/) {
66 my $dir=basename($tool);
67 $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");
[1924]68 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";
[1770]69 print TOOLS "$tooldir/bld\n";
[1467]70 }
[1770]71 if ($tool =~ /\/hponcfg$/) {
72 $ret = system("$tool -w $bkpdir/hponcfg.dat");
[1924]73 print SCRIPT "$tool -r $locbkpdir/hponcfg.dat\n";
[1467]74 }
[1770]75 if ($tool =~ /\.scexe$/) {
[1903]76 print "Found $tool, that firmware will be applied at restore time on your HP Proliant\n";
[1924]77 print SCRIPT "./$tool\n";
[1770]78 }
[1467]79 if ($ret != 0) {
80 print "$tool returned an error. Hardware support may not be complete\n";
81 }
[1280]82 }
[1770]83 close(PROLIANT);
84 close(TOOLS);
85 close(SCRIPT);
[1280]86} else {
[1903]87 print "WARNING: No Hardware support for $productname\n";
[1842]88 print "You may ask your manufacturer to contribute to the mindi project\n";
[1280]89}
[1770]90rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.