1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#!/usr/local/bin/perl -w
#-*- perl -*-
#
# Copyright (C) 2000-2001 Ken'ichi Fukamachi
# All rights reserved.
#
# $Id$
# $FML$
#
use vars qw($MainCF);
use strict;
use Carp;
# main configuration file for directory switch
$MainCF = '/etc/fml/main.cf';
eval { &Bootstrap();};
if ($@) { print STDERR "Error: ", $@, "\n";}
exit 0;
# Firstly we load Standalone.pm which has main.cf parser().
BEGIN {
use File::Basename;
unshift(@INC, dirname($0));
require Standalone;
}
# Descriptions: top lebel bootstrap program
# which load the required library and switch myself to it.
# loading order:
# libexec/fmlwrapper -> libexec/fml -> FML::Process::Something
# Arguments: none
# Side Effects: switch to the real process
# Return Value: none
sub Bootstrap
{
# 1. main.cf exists and I can open it?
-f $MainCF || die("cannot find ${MainCF}");
my $fh = new FileHandle $MainCF;
defined($fh) || die("cannot find ${MainCF}");
# 2. pick up *.cf files to read and set them to @cf.
# We pass it to fml_loader.
# pass *.cf files to libexec/{distribute,command}
# for example
# @cf = ( /etc/fml/defaults/$VERSION/default_config.cf
# /etc/fml/domains/$DOMAIN/config.cf
# /var/spool/ml/elena/config.cf
# );
my @cf = ();
my %options = ();
my $my_default_config = '';
for (@ARGV) {
if ($_ eq '--ctladdr') {
$options{ ctladdr } = 1;
}
elsif ($_ eq '-c') {
$options{ debug } = 1;
}
elsif ($_ eq '-c') {
$my_default_config = shift @ARGV;
}
elsif (-d $_) {
push(@cf, "$_/config.cf") if -f "$_/config.cf";
}
elsif (-f $_) {
push(@cf, $_);
}
}
# 2.1 o.k. try to load main.cf
my $main_cf = Standalone::load_cf($MainCF);
my $libexec_dir = $main_cf->{ libexec_dir };
my $default_config = $my_default_config || $main_cf->{ default_config };
unshift(@cf, $default_config);
# 3. reset @INC
unshift(@INC, $main_cf->{ local_lib_dir }) if $main_cf->{ local_lib_dir };
unshift(@INC, $main_cf->{ lib_dir }) if $main_cf->{ lib_dir };
# 4. inspect my mode from $0
use File::Basename;
my $myname = basename($0);
# 5. o.k. here we go!
require "$libexec_dir/fml";
ProcessSwitch(
{
cf_list => \@cf,
myname => $myname,
options => \%options,
});
}
=head1 NAME
fmlwrapper -- the wrapper which executes a real fml5 program.
=head1 SYNOPSIS
fmlwrapper C<[-c main.cf]> C<[-d]> C<[--ctladdr]> ml_home_dir
=head1 DESCRIPTION
C<-c main.cf>
main.cf alternative
C<-d>
debug on.
C<--ctladdr>
execute fml/libexec/command.
=cut
|