diff options
| author | fukachan <fukachan> | 2001-01-19 12:54:13 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-01-19 12:54:13 +0000 |
| commit | 4377641665acbf1a4a83883241afe392e88ec112 (patch) | |
| tree | 7ed8f24cd168c95d329bcaf2958b6a63feac6bfb /fml/libexec/fmlwrapper | |
| download | fml8-4377641665acbf1a4a83883241afe392e88ec112.tar.gz fml8-4377641665acbf1a4a83883241afe392e88ec112.tar.bz2 fml8-4377641665acbf1a4a83883241afe392e88ec112.zip | |
Initial revision
Diffstat (limited to 'fml/libexec/fmlwrapper')
| -rwxr-xr-x | fml/libexec/fmlwrapper | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/fml/libexec/fmlwrapper b/fml/libexec/fmlwrapper new file mode 100755 index 00000000..33e0d8f1 --- /dev/null +++ b/fml/libexec/fmlwrapper @@ -0,0 +1,103 @@ +#!/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; + + +BEGIN { + use File::Basename; + unshift(@INC, dirname($0)); + require Standalone; +} + + +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}"); + + # 1.1 o.k. try to load main.cf + my $config = Standalone::load_cf($MainCF); + my $libexec_dir = $config->{ libexec_dir }; + my $default_config = $config->{ default_config }; + + # 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 = ($default_config); + my %optargs = (); + for (@ARGV) { + if ($_ eq '--ctladdr') { + $optargs{ ctladdr } = 1; + } + elsif (-d $_) { + push(@cf, "$_/config.cf") if -f "$_/config.cf"; + } + elsif (-f $_) { + push(@cf, "$_"); + } + } + + # 3. reset @INC + use lib qw( $config->{ local_lib_dir } $config->{ 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( + { + main_config => $config, + cf_list => \@cf, + myname => $myname, + options => \%optargs, + }); +} + + +=head1 NAME + +fml.pl -- wrapper which executes the real fml5 programs. + +=head1 SYNOPSIS + +fml.pl C<[-d]> C<[--ctladdr]> $mail_list_address + +=head1 DESCRIPTION + +C<$mail_list_address> + Hmm,,,? + +C<-d> + debug on. + +C<--ctladdr> + execute fml/libexec/command. + +=cut |
