source: ProjectBuilder/projects/casparbuster/devel/lib/CasparBuster/Plugin.pm@ 1485

Last change on this file since 1485 was 1485, checked in by Bruno Cornec, 12 years ago
  • Adds a Plugin module to support plugin management
  • cbusterize now works with both -s and -p options
  • One plugin example added (dhcpd)

-cb script started. Not working now

File size: 2.5 KB
Line 
1#
2# Manages Plugins for CasparBuster
3#
4# $Id$
5#
6#
7package CasparBuster::Plugin;
8
9use strict;
10use warnings;
11use CasparBuster::Env;
12use ProjectBuilder::Base;
13use ProjectBuilder::Conf;
14use Data::Dumper;
15
16# Global vars
17# Inherit from the "Exporter" module which handles exporting functions.
18#
19use vars qw($VERSION $REVISION @ISA @EXPORT);
20use Exporter;
21#
22# Export, by default, all the functions into the namespace of
23# any code which uses this module.
24
25our @ISA = qw(Exporter);
26our @EXPORT = qw(cb_plugin_load cb_plugin_get);
27
28=pod
29
30=head1 NAME
31
32CasparBuster::Plugin - module dealing with CasparBuster plugin management
33
34=head1 DESCRIPTION
35
36This modules provides functions to allow the management of CasparBuster plugins
37
38=head1 SYNOPSIS
39
40 use CasparBuster::Plugin;
41
42=head1 USAGE
43
44=over 4
45
46=item B<cb_plugin_load>
47
48This function loads all the plugins defined for this CasparBuster environement
49
50=cut
51
52sub cb_plugin_load {
53
54my ($pluginsdir) = pb_conf_get("cbpluginssubdir");
55my $cbconfdir = cb_env_confdir()."/$pluginsdir->{$ENV{'PBPROJ'}}";
56opendir(DIR,$cbconfdir) || die "Unable to open $cbconfdir: $!";
57foreach my $f (readdir(DIR)) {
58 next if ($f =~ /^\./);
59 # Add on plugins files
60 if ($f =~ /\.conf$/) {
61 pb_conf_add("$cbconfdir/$f") if (-f "$cbconfdir/$f");
62 }
63}
64closedir(DIR);
65}
66
67
68=item B<cb_plugin_get>
69
70This function adds into the plugin hash, passed as second parameter, the new plugin content based on its name, passed as first parameter.
71
72=cut
73
74sub cb_plugin_get {
75
76my $plugin = shift;
77my $cbp = shift;
78
79my ($flist,$dlist,$slist) = pb_conf_get_if("cbpluginfiles","cbplugindirs","cbpluginreload");
80if ((defined $flist) && (defined $flist->{$plugin}) && ($flist->{$plugin} !~ /^\s*$/)) {
81 foreach my $block (split(/;/,$flist->{$plugin})) {
82 pb_log(3,"block : $block\n");
83 my ($name,$tmp) = split(/\|/,$block);
84 ($cbp->{$plugin}->{'files'}->{$name}->{'uid'},$cbp->{$plugin}->{'files'}->{$name}->{'gid'},$cbp->{$plugin}->{'files'}->{$name}->{'mode'}) = split(/\,/,$tmp);
85 }
86}
87if ((defined $dlist) && (defined $dlist->{$plugin}) && ($dlist->{$plugin} !~ /^\s*$/)) {
88 my $i = 0;
89 foreach my $block (split(/;/,$dlist->{$plugin})) {
90 pb_log(3,"block : $block\n");
91 my $tmp;
92 ($cbp->{$plugin}->{'dirs'}->{'name'}[$i],$tmp) = split(/\|/,$block);
93 ($cbp->{$plugin}->{'dirs'}->{'uid'}[$i],$cbp->{$plugin}->{'dirs'}->{'gid'}[$i],$cbp->{$plugin}->{'dirs'}->{'mode'}[$i]) = split(/\,/,$tmp);
94 $i++;
95 }
96}
97if ((defined $slist) && (defined $slist->{$plugin})) {
98 $cbp->{$plugin}->{'reloadscript'} = $slist->{$plugin};
99}
100pb_log(2,"cbp: ".Dumper($cbp)."\n");
101return($cbp);
102}
103
1041;
Note: See TracBrowser for help on using the repository browser.