source: devel/mrmini/sbin/mrmini @ 2667

Last change on this file since 2667 was 2667, checked in by bruno, 8 years ago

r3936@dhcp184-49-175-19: bruno | 2010-06-26 09:48:04 +0200

  • Inventory now in better shape. Needs useful and exhaustive content now.
File size: 5.4 KB
Line 
1#!/usr/bin/perl -w
2#
3# mrmini main application
4# Mini-distribution maker for the MondoRescue project
5#
6# $Id$
7#
8# Copyright B. Cornec 2008-2010
9# Provided under the GPL v2
10
11# Syntax: see below
12
13use strict 'vars';
14use Getopt::Long qw(:config auto_abbrev no_ignore_case);
15use Data::Dumper;
16use English;
17use File::Basename;
18use File::Copy;
19use File::stat;
20use Digest::MD5 qw(md5_hex);
21use lib qw (lib);
22use POSIX qw(strftime);
23use ProjectBuilder::Base;
24use ProjectBuilder::Conf;
25use ProjectBuilder::Distribution;
26use ProjectBuilder::Display;
27use MondoRescue::LVM;
28use MondoRescue::Base;
29use MondoRescue::DynConf;
30use MondoRescue::Mini::Base;
31
32=pod
33
34=head1 NAME
35
36mrmini - Tool to create a boot environment from a distribution
37
38=head1 DESCRIPTION
39
40B<mrmini> creates a bootable ISO/USB image using files from the system it runs on. B<mrmini> will try hard to reproduce the environment of its host system including loaded modules to ensure that the system can be booted properly from the created rescue media. B<mrmini> is used by monodarchive(8) to produce the required USB/ISO images but can also be used stand-alone.
41
42For stand-alone usage, B<mrmini> may be called without any parameters or switches. It will then interactively ask the user for all information required to create a set of boot/root media. Options on the command line or a configuration file can also be used to alter the way B<mrmini> is working
43
44The probably more frequent way of calling B<mrmini> is non-interactively from mondoarchive(8) using a dedicated configuration file.
45
46=head1 SYNOPSIS
47
48mrmini [-v]|[-q]|[-h]|[--man]
49
50=head1 OPTIONS
51
52=cut
53
54# Handle options
55#
56
57=pod
58=over 4
59=item B<-v|--verbose>
60
61Print a brief help message and exits.
62
63=item B<-q|--quiet>
64
65Do not print any output.
66
67=item B<-h|--help>
68
69Print a brief help message and exits.
70
71=item B<--man>
72
73Prints the manual page and exits.
74
75=item B<-i|--iso iso_image>
76
77Name of the ISO image you want to created.
78
79=item B<-u|--usb usb_device>
80
81Name of the USB device on which you want to created your image.
82
83=item B<-t|--tape tape_device>
84
85Name of the Tape device on which you want to created your image.
86
87=item B<-o|--obdr>
88
89Activate OBDR mode for tape (Bootable tape devices)
90
91=item B<-V|--version>
92
93Display mrmini version and exit
94
95=item B<-f|--force>
96
97Force usage of defaults parameters or values without asking questions
98
99=item B<-p|--printvars variable>
100
101Prints the value of the variable passed as parameter
102
103=cut
104
105# Global variables
106my %opts;                   # CLI Options
107
108GetOptions(
109        "verbose|v+" => \$opts{'v'},
110        "quiet|q" => \$opts{'q'},
111        "help|?|h" => \$opts{'h'}, 
112        "man" => \$opts{'man'},
113        "iso|i=s" => \$opts{'i'},
114        "usb|u=s" => \$opts{'u'},
115        "tape|t=s" => \$opts{'t'},
116        "obdr|o" => \$opts{'o'},
117        "version|V" => \$opts{'V'},
118        "force|f" => \$opts{'f'},
119        "printvar|p=s" => \$opts{'p'},
120        "log-files|l=s" => \$opts{'l'},
121) || pb_syntax(-1,0);
122
123=pod
124=back
125
126=head1 WEB SITES
127
128The main Web site of the project is available at L<http://www.mondorescue.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.mondorescue.org/>.
129
130=head1 USER MAILING LIST
131
132The miling list of the project is available at L<mailto:mondo@lists.sf.net>
133
134=head1 CONFIGURATION FILES
135
136The system administrator may have a configuration file in F<$HOME/.mondorescue>. The values in this file may overwrite any other configuration file value.
137
138Here is an example of such a configuration file:
139
140 # mrcachedir points to the directory where the tool will store generated content
141 # If not defined, mrcachedir is under /var/cache/mrmini
142 mrcachedir mrmini = /var/cache/mrmini
143
144 Also look at man mrmini.conf
145 
146=head1 AUTHORS
147
148The Mondorescue.org team L<http://www.mondorescue.org/> lead by Bruno Cornec L<mailto:bruno@mondorescue.org>.
149
150=head1 COPYRIGHT
151
152mrmini is distributed under the GPL v2.0 license
153described in the file C<COPYING> included with the distribution.
154
155=cut
156
157
158
159# ---------------------------------------------------------------------------
160
161# Catch signals
162$SIG{INT} = \&mr_exit;
163$SIG{QUIT} = \&mr_exit;
164$SIG{ABRT} = \&mr_exit;
165$SIG{KILL} = \&mr_exit;
166$SIG{TERM} = \&mr_exit;
167
168#
169# Global variables
170#
171my $proj;
172($mr->{'confdir'},$proj) = mr_dynconf_init();
173my @date = pb_get_date();
174$mr->{'start_date'} = strftime("%Y-%m-%d %H:%M:%S", @date);
175
176$ENV{'PBPROJ'} = $proj;
177$ENV{'PBPKG'} = "mrmini";
178
179# Adds conf files in order
180pb_conf_add("$mr->{'confdir'}/mondorescue.conf.dist","$mr->{'confdir'}/mondorescue.conf");
181($mr->{'install_dir'},$mr->{'version'}) =  mr_conf_get("mr_install_dir","mr_version");
182
183# Initialize the syntax string
184pb_syntax_init("$ENV{'PBPKG'} Version $mr->{'version'}\n");
185pb_display_init("text","");
186
187# easy options
188if (defined $opts{'h'}) {
189    pb_syntax(0,1);
190}
191if (defined $opts{'man'}) {
192    pb_syntax(0,2);
193}
194if (defined $opts{'p'}) {
195    pb_display("$ENV{$opts{'p'}}\n");
196    exit(0);
197}
198
199if (defined $opts{'v'}) {
200    $pbdebug = $opts{'v'};
201}
202
203my $force = 0;
204
205if (defined $opts{'f'}) {
206    $force=1;
207}
208if (defined $opts{'q'}) {
209    $pbdebug=-1;
210}
211my $iso;
212
213if (defined $opts{'i'}) {
214    $iso = $opts{'i'};
215}
216my $logfile = undef;
217if (defined $opts{'l'}) {
218    # Log file forced externally
219    $logfile = $opts{'l'};
220} elsif ($pbdebug ge 1) {
221    # Log file forced internally to default value as we are in debug mode
222    ($logfile) =  mr_conf_get("mr_logfile");
223}
224
225if (defined $logfile) {
226    open(pbLOG,"> $logfile") || die "Unable to log to $logfile: $!";
227    $mr->{'logdesc'} = \*pbLOG;
228} else {
229    $mr->{'logdesc'} = undef;
230}
231
232#
233# Temp dir
234#
235pb_temp_init();
236mr_mini_main();
237mr_exit(0);
Note: See TracBrowser for help on using the repository browser.