source: branches/2.2.5/mindi/mindi-bkphw @ 1764

Last change on this file since 1764 was 1764, checked in by Bruno Cornec, 13 years ago
  • perl is now required at restore time to support uuid swap partitions (and will be used for many other thigs in the future for sure)
  • next mindi version will be 2.0.0 due to all the changes made in it (udev may break working distros)
  • small optimization in mindi on keyboard handling (one single find instead of multiple)
  • better interaction for USB device when launching mindi manually
  • attempt to automatically guess block disk size for ramdisk
  • fix typos in bkphw
File size: 2.6 KB
Line 
1#!/usr/bin/perl -w
2#
3# Backup the hardware configuration on machine supporting it
4# (Bios configuration, Raid configuration, ...)
5#
6use strict;
7use File::Basename;
8
9# Handling Configuration files
10my $tool = "";
11my $tooldir = "";
12my $ret = 0;
13
14die "No CACHE_DIR parameter" if ((not defined $ARGV[0]) || (! -d $ARGV[0]));
15my $bkpdir = "$ARGV[0]/bkphw";
16die "No CONF_DIR parameter" if ((not defined $ARGV[1]) || (! -d $ARGV[1]));
17my $confdir = "$ARGV[1]";
18
19mkdir 0755,$bkpdir if (! -d $bkpdir) ;
20open(SYSTEM,"dmidecode -s 'system-product-name' |") || die "You need dmidecode for mindi hardware support";
21my $productname = <SYSTEM>;
22close(SYSTEM);
23
24chomp($productname);
25if ($productname =~ /proliant/i) {
26    print "Detected an HP Hardware. Nice. Continue to support my job :-)\n";
27    print "Activating Proliant support for mindi\n";
28    open(PROLIANT,"$confdir/proliant.files") || die "Unable to open $confdir/proliant.files";
29    open(TOOLS,"> $bkpdir/../tools.files") || die "Unable to open $bkpdir/../tools.files";
30    open(SCRIPT,"> $bkpdir/../mindi-rsthw") || die "Unable to open $bkpdir/../mindi-rsthw";
31    print SCRIPT  << "EOF";
32#!/bin/bash
33#
34# This script will restore potentially your HW configuration
35# on your system before partioning occurs
36# You may want to reboot after that step if you think that
37# resetting BIOS parameters to the value restored
38# may have an impact on you restoration process
39#
40EOF
41    while($tool = <PROLIANT>) {
42        next if ($tool =~ /^#/);
43        chomp($tool);
44        $tooldir = dirname($tool);
45        if (! (-e $tool)) {
46            print "You should install the SmartStart Scripting toolkit tool $tool\nto benefit from mindi's enhanced hardware support\n";
47            print "Get it from http://www.hp.com/servers/sstoolkit\n";
48            next;
49        } else {
50            print "Found $tool, activating enhanced HP Proliant support in mindi\n";
51            print TOOLS "$tool\n";
52        }
53        if ($tool =~ /\/conrep$/) {
54            $ret = system("(cd $tooldir ; $tool -s -f$bkpdir/conrep.dat)");
55            print SCRIPT "(cd $tooldir ; $tool -s -f$bkpdir/conrep.dat)");
56            print TOOLS "$tool.xml\n";
57        }
58        if ($tool =~ /\/cpqacuxe$/) {
59            $ret = system("$tool -c $bkpdir/cpqacuxe.dat");
60            print SCRIPT "$tool -r $bkpdir/cpqacuxe.dat");
61            print TOOLS "$tooldir/bld\n";
62        }
63        if ($tool =~ /\/hponcfg$/) {
64            $ret = system("$tool -w $bkpdir/hponcfg.dat");
65            print SCRIPT "$tool -r $bkpdir/hponcfg.dat");
66        }
67        if ($tool =~ /\.scexe$/) {
68            print SCRIPT "$tool");
69        }
70        if ($ret != 0) {
71            print "$tool returned an error. Hardware support may not be complete\n";
72        }
73    }
74    close(PROLIANT);
75    close(TOOLS);
76    close(SCRIPT);
77} else {
78    print "No Hardware support for $productname\n";
79    print "Ask your manufacturer to contribute to the mindi project\n";
80}
81rmdir $bkpdir if (-d $bkpdir) ;
Note: See TracBrowser for help on using the repository browser.