62 lines
1.8 KiB
Plaintext
62 lines
1.8 KiB
Plaintext
|
#! /usr/bin/perl -w
|
||
|
#----------------------------------------------------------------------
|
||
|
# copyright (C) 2003-2007 Mitel Networks Corporation
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation; either version 2 of the License, or
|
||
|
# (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
|
#
|
||
|
#----------------------------------------------------------------------
|
||
|
|
||
|
use strict;
|
||
|
use File::Find;
|
||
|
use File::Copy;
|
||
|
use esmith::templates;
|
||
|
|
||
|
sub expand;
|
||
|
|
||
|
my $event = shift or die "Event name is required\n";
|
||
|
|
||
|
my $filename;
|
||
|
my %args;
|
||
|
my ($param, $value);
|
||
|
my $templates_dir = "/etc/e-smith/events/$event/templates2expand";
|
||
|
exit 0 unless -d $templates_dir;
|
||
|
|
||
|
chdir $templates_dir or die "Could not chdir to $templates_dir: $!\n";;
|
||
|
# Walk the tree and expand all templates referenced thereunder.
|
||
|
find({
|
||
|
no_chdir => 1,
|
||
|
follow => 0,
|
||
|
wanted => \&expand,
|
||
|
},
|
||
|
'.'
|
||
|
);
|
||
|
|
||
|
exit 0;
|
||
|
|
||
|
sub expand
|
||
|
{
|
||
|
return unless -f $_;
|
||
|
# For each file found, read the file to find
|
||
|
# processTemplate args, then expand the template
|
||
|
s/^\.//;
|
||
|
$filename = $_;
|
||
|
warn "expanding $filename\n";
|
||
|
esmith::templates::processTemplate({
|
||
|
MORE_DATA => { EVENT => $event },
|
||
|
TEMPLATE_PATH => $filename,
|
||
|
OUTPUT_FILENAME => $filename,
|
||
|
});
|
||
|
}
|