- Timestamp:
- Apr 30, 2012, 2:58:47 AM (13 years ago)
- Location:
- projects/casparbuster/devel
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
projects/casparbuster/devel/bin/cb
r1490 r1494 257 257 $cbp = cb_plugin_get($p,$cbp); 258 258 # Adds mtime info to the plugin structure 259 foreach my $type ('files','dirs' ) {259 foreach my $type ('files','dirs','dirsandfiles') { 260 260 foreach my $f (keys %{$cbp->{$p}->{$type}}) { 261 261 my $tdir = $dest; … … 282 282 my $type = 'files'; 283 283 if (-d $fullsource) { 284 $type = 'dirs ';284 $type = 'dirsandfiles'; 285 285 } 286 286 die "ERROR: Only able to handle files or dirs with option --source\n" if ((! -d $fullsource) && (! -f $fullsource)); … … 321 321 # Check what in cbp is in the DB and deploy only if necessary 322 322 foreach my $k (keys %{$cbp}) { 323 foreach my $type ('files','dirs' ) {323 foreach my $type ('files','dirs','dirsandfiles') { 324 324 foreach my $o (keys %{$cbp->{$k}->{$type}}) { 325 325 # Compare with info from DB … … 353 353 my $curdate = time(); 354 354 foreach my $k (keys %{$cbp}) { 355 foreach my $type ('files','dirs') { 355 foreach my $type ('files','dirs','dirsandfiles') { 356 # TODO: for dirs we may remove the files below ? 356 357 foreach my $o ((keys %{$cbp->{$k}->{$type}})) { 357 358 if (not defined $cbp->{$k}->{$type}->{$o}->{'deleted'}) { … … 426 427 427 428 foreach my $k (keys %{$cbp}) { 428 foreach my $type ('files','dirs') { 429 foreach my $type ('files','dirs','dirsandfiles') { 430 # TODO: do we act recursively for dirsandfiles at least for uid/gid ? 429 431 foreach my $o ((keys %{$cbp->{$k}->{$type}})) { 430 432 if (not defined $cbp->{$k}->{$type}->{$o}->{'deleted'}) { … … 441 443 if (defined $cbp->{$k}->{'reloadscript'}) { 442 444 if ($debug) { 443 pb_log(1,"INFO: Executing (on $mac) sudo$cbp->{$k}->{'reloadscript'}\n");445 pb_log(1,"INFO: Executing (on $mac) $cbp->{$k}->{'reloadscript'}\n"); 444 446 } else { 445 &$func(" sudo$cbp->{$k}->{'reloadscript'}");447 &$func("$cbp->{$k}->{'reloadscript'}"); 446 448 } 447 449 } -
projects/casparbuster/devel/bin/cbusterize
r1487 r1494 115 115 use Pod::Usage; 116 116 use Data::Dumper; 117 use Net::SSH2; 117 118 use ProjectBuilder::Base; 118 119 use ProjectBuilder::Conf; … … 202 203 # Use potentially a remote account if defined 203 204 my $account = undef; 204 my $remote = $machine;205 my $remote = undef; 205 206 ($account) = pb_conf_get_if("cbaccount") if (defined $machine); 206 $remote = $account->{$machine}."@".$machine if ((defined $account) && (defined $account->{$machine})); 207 pb_log(1, "DEBUG: remote = $remote\n") if (defined $remote); 207 $remote = $account->{$machine} if ((defined $account) && (defined $machine) && (defined $account->{$machine})); 208 pb_log(1, "DEBUG: remote account1 = $remote\n") if (defined $remote); 209 $remote = getpwuid($<) if (not defined $remote); 210 pb_log(1, "DEBUG: remote account2 = $remote\n"); 208 211 209 212 # Create basedir if it doesn't exist … … 218 221 if (defined $source) { 219 222 foreach my $f (split(/,/,$source)) { 220 cb_busterize($f );223 cb_busterize($f,"true"); 221 224 } 222 225 } … … 230 233 $cbp = cb_plugin_get($p,$cbp); 231 234 pb_log(2,"cbp: ".Dumper($cbp)."\n"); 232 foreach my $k ((keys %{$cbp->{$plugin}->{'files'}}),(keys %{$cbp->{$plugin}->{'dirs'}})) { 233 cb_busterize($k); 235 foreach my $k (keys %{$cbp->{$plugin}->{'dirsandfiles'}}) { 236 cb_busterize($k,"true"); 237 } 238 foreach my $k ((keys %{$cbp->{$plugin}->{'dirs'}}),(keys %{$cbp->{$plugin}->{'files'}})) { 239 cb_busterize($k,"false"); 234 240 } 235 241 } … … 239 245 240 246 my $source = shift; 247 my $recur = shift; 241 248 242 249 pb_log(2,"Entering cb_busterize source: $source\n"); … … 245 252 my $srcfile = undef; 246 253 my $cmd = undef; 254 my $ssh2; 255 my $sftp; 247 256 248 257 if (not defined $machine) { … … 254 263 } 255 264 } else { 256 $cmd = "ssh -q $remote \'echo \"if [ -d $source ]; then exit 0; else exit -1; fi\" | sudo bash\'"; 257 my $res = pb_system($cmd,"","quiet"); 258 pb_log(2,"DEBUG: Found res = $res\n"); 259 if ($res == 0) { 260 $srcdir = $source; 261 pb_log(1,"DEBUG: Found remote dir = $source\n"); 262 } else { 263 $srcdir = dirname($source); 264 $srcfile = basename($source); 265 pb_log(1,"DEBUG: Found remote file = $source\n"); 265 $ssh2 = Net::SSH2->new(); 266 $ssh2->connect($machine); 267 my $hdir = (getpwnam(getpwuid($<)))[7]; 268 if ($ssh2->auth_publickey($remote,"$hdir/.ssh/id_dsa.pub","$hdir/.ssh/id_dsa")) { 269 $sftp = $ssh2->sftp; 270 my %dirs = $sftp->stat("$source/."); 271 my $res = 0; 272 $res = -1 if (not defined $dirs{'mode'}); 273 pb_log(2,"DEBUG: Found res = $res\n"); 274 if ($res == 0) { 275 $srcdir = $source; 276 pb_log(1,"DEBUG: Found remote dir = $source\n"); 277 } else { 278 $srcdir = dirname($source); 279 $srcfile = basename($source); 280 pb_log(1,"DEBUG: Found remote file = $source\n"); 281 } 266 282 } 267 283 } … … 284 300 $target = basename($target) if ((not defined $srcfile) && (-d $target)); 285 301 286 # Create target if it doesn't exist when we have to copy a file287 if ( (not -d $target) && (defined $srcfile)) {302 # Create target if it doesn't exist 303 if (not -d $target) { 288 304 if ($debug) { 289 305 pb_log(1,"DEBUG: Creating recursively directory $target\n"); 290 306 } else { 291 307 pb_mkdir_p($target) || die "Unable to recursively create $target: $!"; 292 pb_vcs_add($scheme,$target); 293 pb_log(0,"INFO: Created $target and added it to your $scheme system\n"); 308 } 309 # Add all the dirs in it to VCS (in reverse order) 310 my $tdir = $target; 311 my @tab = (); 312 while ($tdir ne $basedir) { 313 push(@tab,$tdir); 314 $tdir = dirname($tdir); 315 pb_log(3,"tdir is now $tdir\n"); 316 } 317 if ($debug) { 318 pb_log(0,"INFO: Added to your $scheme system the dirs: ".join(' ',reverse(@tab))."\n"); 319 } else { 320 pb_vcs_add($scheme,reverse(@tab)); 294 321 } 295 322 } … … 302 329 303 330 if (defined $machine) { 304 $cmd = "scp -p -q $cmdopt $remote :$source$target";331 $cmd = "scp -p -q $cmdopt $remote\@$machine:\'$source\' $target"; 305 332 } else { 306 333 $cmd = "cp -p $cmdopt $source $target"; … … 310 337 if (defined $srcfile) { 311 338 # File case 312 if ((! -f "$target/$srcfile") || (defined $force)) {339 if ((! -f "$target/$srcfile") || (defined $force)) { 313 340 if ($debug) { 314 341 pb_log(1,"DEBUG: launching $cmd\n"); … … 324 351 # Directory case 325 352 if ($debug) { 326 pb_log(1,"DEBUG: launching $cmd\n"); 327 } else { 328 pb_system($cmd); 353 if ($recur eq "true") { 354 pb_log(1,"DEBUG: launching $cmd\n"); 355 } else { 356 pb_log(1,"DEBUG: mkdir -p $target\n"); 357 } 358 } else { 359 if ($recur eq "true") { 360 pb_system($cmd); 361 } 329 362 pb_vcs_add($scheme,"$target"); 330 363 pb_log(0,"INFO: Created $target and added it to your $scheme system\n"); 331 364 } 332 365 } 366 $ssh2->disconnect() if (defined $machine); 333 367 pb_log(2,"Exiting cb_busterize\n"); 334 368 } -
projects/casparbuster/devel/lib/CasparBuster/Plugin.pm
r1490 r1494 78 78 79 79 pb_log(2,"Entering cb_plugin_get for plugin $plugin\n"); 80 my ($flist,$dlist,$ slist) = pb_conf_get_if("cbpluginfiles","cbplugindirs","cbpluginreload");80 my ($flist,$dlist,$dflist,$slist) = pb_conf_get_if("cbpluginfiles","cbplugindirs","cbplugindirsandfiles","cbpluginreload"); 81 81 if ((defined $flist) && (defined $flist->{$plugin}) && ($flist->{$plugin} !~ /^\s*$/)) { 82 82 foreach my $block (split(/;/,$flist->{$plugin})) { … … 93 93 } 94 94 } 95 if ((defined $dflist) && (defined $dflist->{$plugin}) && ($dflist->{$plugin} !~ /^\s*$/)) { 96 foreach my $block (split(/;/,$dflist->{$plugin})) { 97 pb_log(3,"block : $block\n"); 98 my ($name,$tmp) = split(/\|/,$block); 99 ($cbp->{$plugin}->{'dirsandfiles'}->{$name}->{'uid'},$cbp->{$plugin}->{'dirsandfiles'}->{$name}->{'gid'},$cbp->{$plugin}->{'dirsandfiles'}->{$name}->{'mode'}) = split(/\,/,$tmp); 100 } 101 } 95 102 if ((defined $slist) && (defined $slist->{$plugin})) { 96 103 $cbp->{$plugin}->{'reloadscript'} = $slist->{$plugin};
Note:
See TracChangeset
for help on using the changeset viewer.