Changeset 1679 in ProjectBuilder for projects/casparbuster


Ignore:
Timestamp:
Nov 16, 2012, 9:07:07 PM (11 years ago)
Author:
Bruno Cornec
Message:
  • Start working on plugins
Location:
projects/casparbuster/devel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • projects/casparbuster/devel/bin/cb

    r1667 r1679  
    281281    die "ERROR: Only able to handle files or dirs with option --source\n" if ((! -d $fullsource) && (! -f $fullsource));
    282282
    283     # We should get uid/gid fro elsewhere as they're probably wrong locally
     283    # We should get uid/gid from elsewhere as they're probably wrong locally
    284284    $cbp->{"cb.source"}->{$type}->{$source}->{'uid'} = $uid;
    285285    $cbp->{"cb.source"}->{$type}->{$source}->{'gid'} = $gid;
     
    294294    $findtarget = "$dest/$machine";
    295295    find(\&cb_add_to_cbp,($findtarget));
     296    # And we also need all what is common, but not what is for the web side
     297    foreach my $c (keys $cb->{'commondir'}) {
     298        $findtarget = "$dest/$c";
     299        opendir(DIR,"$findtarget") || die "Unable to open $dest/$c: $!";
     300        foreach my $m (readdir(DIR)) {
     301            next if ($m =~ /^\./);
     302            next if ($m eq $cb->{'commondir'}->{$c});
     303            find(\&cb_add_to_cbp,("$findtarget/$m"));
     304        }
     305        closedir(DIR);
     306    }
    296307}
    297308pb_log(1,"INFO: RAW cbp: ".Dumper(%$cbp)."\n");
     
    415426            if ((defined $force) || (not defined $cbp->{$k}->{$type}->{$o}->{'deleted'})) {
    416427                if ($debug) {
    417                     pb_log(1,"INFO: Executing (on $machine) sudo chown $cbp->{$k}->{$type}->{$o}->{'uid'}:$cbp->{$k}->{$type}->{$o}->{'gid'} $path/$o\n");
     428                    #pb_log(1,"INFO: Executing (on $machine) sudo chown $cbp->{$k}->{$type}->{$o}->{'uid'}:$cbp->{$k}->{$type}->{$o}->{'gid'} $path/$o\n");
    418429                    #pb_log(1,"INFO: Executing (on $machine) sudo chmod $cbp->{$k}->{$type}->{$o}->{'mode'} $path/$o\n");
    419430                } else {
    420431                    # TODO: remove hardcoded commands
    421                     print $chan "sudo chown $cbp->{$k}->{$type}->{$o}->{'uid'}:$cbp->{$k}->{$type}->{$o}->{'gid'} $path/$o\n";
     432                    #print $chan "sudo chown $cbp->{$k}->{$type}->{$o}->{'uid'}:$cbp->{$k}->{$type}->{$o}->{'gid'} $path/$o\n";
    422433                    # TODO: get a correct mode before setting it up
    423434                    #print $chan "sudo chmod $cbp->{$k}->{$type}->{$o}->{'mode'} $path/$o\n";
  • projects/casparbuster/devel/bin/cbusterize

    r1668 r1679  
    215215pb_log(1, "DEBUG: remote account2 = $remote\n");
    216216
     217$ssh2 = cb_ssh_init($remote,$machine,$debug) if (not defined $ssh2);
     218
    217219# Create basedir if it doesn't exist
    218220if (not -d $basedir) {
     
    236238    foreach my $p (split(/,/,$plugin)) {   
    237239        pb_log(1,"Getting context for plugin $p\n");
    238         $cbp = cb_plugin_get($p,$cbp);
     240        $cbp = cb_plugin_get($p,$cbp,$remote,$machine,$debug,$ssh2);
    239241        pb_log(2,"cbp: ".Dumper($cbp)."\n");
    240242        foreach my $k (keys %{$cbp->{$plugin}->{'dirsandfiles'}}) {
     
    260262my $realsrc = "";
    261263my $type = "";
    262 
    263 $ssh2 = cb_ssh_init($remote,$machine,$debug) if (not defined $ssh2);
    264264
    265265$chan = $ssh2->channel();
  • projects/casparbuster/devel/etc/cb/plugins/shorewall.conf

    r1547 r1679  
    2020#=cut
    2121#
    22 cbpluginfiles shorewall = /etc/shorewall/*|root,root,0600
     22#cbpluginfiles shorewall = /etc/shorewall/*|root,root,0600
    2323#
    2424#=item B<cbplugindirs>
     
    3030#
    3131#=cut
    32 cbplugindirs shorewall = /etc/shorewall|root,root,0750
     32#cbplugindirs shorewall = /etc/shorewall|root,root,0750
    3333#
    3434#=item B<cbplugindirsandfiles>
     
    4040#
    4141#=cut
    42 cbplugindirsandfiles shorewall =
     42#cbplugindirsandfiles shorewall =
    4343#
    44 #=item B<cbpluginreload>
     44#=item B<cbpluginpkgs>
    4545#
    46 # Define the command to launch remotely on the target machine to reload the service.
     46# Define the list of packages to consider remotely on the target machine.
     47# Parameters are ',' separated.
    4748#
    4849#=cut
    49 cbpluginreload shorewall = sudo /etc/init.d/shorewall restart
     50cbpluginpkgs shorewall = shorewall
     51#
     52#=item B<cbpkgreload>
     53#
     54# Define the command to launch remotely on the target machine to reload the service og this package.
     55#
     56#=cut
     57cbpkgreload shorewall = sudo /etc/init.d/shorewall restart
  • projects/casparbuster/devel/lib/CasparBuster/Plugin.pm

    r1494 r1679  
    99use strict;
    1010use warnings;
     11use Carp;
    1112use CasparBuster::Env;
    1213use ProjectBuilder::Base;
     
    7677my $plugin = shift;
    7778my $cbp = shift;
     79my $remote = shift;
     80my $machine = shift;
     81my $debug = shift;
     82my $ssh2 = shift;
    7883
    7984pb_log(2,"Entering cb_plugin_get for plugin $plugin\n");
    80 my ($flist,$dlist,$dflist,$slist) = pb_conf_get_if("cbpluginfiles","cbplugindirs","cbplugindirsandfiles","cbpluginreload");
     85my ($flist,$dlist,$dflist,$slist,$plist) = pb_conf_get_if("cbpluginfiles","cbplugindirs","cbplugindirsandfiles","cbppkgreload","cbpluginpkgs");
    8186if ((defined $flist) && (defined $flist->{$plugin}) && ($flist->{$plugin} !~ /^\s*$/)) {
    8287    foreach my $block (split(/;/,$flist->{$plugin})) {
     
    100105    }
    101106}
    102 if ((defined $slist) && (defined $slist->{$plugin})) {
    103     $cbp->{$plugin}->{'reloadscript'} = $slist->{$plugin};
     107if ((defined $plist) && (defined $plist->{$plugin})) {
     108    foreach my $name (split(/,/,$plist->{$plugin})) {
     109        $cbp->{$plugin}->{'pkgs'}->{$name}->{'name'} = $name;
     110        if ((defined $slist) && (defined $slist->{$name})) {
     111            $cbp->{$plugin}->{'pkgs'}->{$name}->{'restart'} = $slist->{$name};
     112        }
     113    }
     114} else {
     115    $cbp->{$plugin}->{'pkgs'}->{$plugin}->{'name'} = $plugin;
    104116}
     117# Check remotely what conf files are needed for this plugin through its packages
     118$ssh2 = cb_ssh_init($remote,$machine,$debug) if (not defined $ssh2);
     119
     120my $chan = $ssh2->channel();
     121pb_log(3,"DEBUG: SSH2 chan called\n");
     122confess "Unable to create channel for $remote\@$machine: $!" if (not defined $chan);
     123if ($debug) {
     124    pb_log(1,"DEBUG: launching a shell via Net:SSH2 ($remote\@$machine)\n");
     125}
     126confess "Unable to launch remote shell through Net:SSH2 ($remote\@$machine)" if (not $chan->shell());
     127pb_log(3,"DEBUG: SSH2 shell called\n");
     128
     129foreach my $p (keys $cbp->{$plugin}->{'pkgs'}) {
     130    # TODO: Do not hardcode rpm
     131    my $cmd = "sudo rpm -q -c --dump $p";
     132    pb_log(2,"DEBUG: Calling $cmd\n");
     133    print $chan "$cmd\n";
     134    while (<$chan>) {
     135        my ($name,$d1,$d2,$d3,$mode,$uid,$gid,$dummy) = split(/ /,$_);
     136        $cbp->{$plugin}->{'files'}->{$name}->{'uid'} = $uid;
     137        $cbp->{$plugin}->{'files'}->{$name}->{'gid'} = $gid;
     138        $cbp->{$plugin}->{'files'}->{$name}->{'mode'} = substr($mode,4,);
     139        pb_log(3,"DEBUG: Found $name");
     140    }
     141}
     142
     143$chan->close();
     144
    105145pb_log(2,"cbp: ".Dumper($cbp)."\n");
    106146return($cbp);
Note: See TracChangeset for help on using the changeset viewer.