Changeset 1683 in ProjectBuilder for projects/casparbuster


Ignore:
Timestamp:
Jan 3, 2013, 5:02:53 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • Fix tar build to include also common files
  • Use ssh instead of Net:SSH2 to lauch the final setup script as it wasn't working for a reason
  • Use sudo to lauch these scripts, which require norequiretty fin sudoers for the account used
Location:
projects/casparbuster/devel
Files:
2 edited

Legend:

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

    r1682 r1683  
    350350
    351351my $tar = Archive::Tar->new;
    352 $tar->setcwd($tdir);
    353352my $curdate = time();
    354353foreach my $k (keys %{$cbp}) {
     
    357356        foreach my $o ((keys %{$cbp->{$k}->{$type}})) {
    358357            if ((defined $force) || (not defined $cbp->{$k}->{$type}->{$o}->{'deleted'})) {
    359                 $tar->add_files("$o");
     358                if ( -r "$tdir/$o" ) {
     359                    pb_log(1,"INFO: Adding to the tar file $tdir/$o\n");
     360                    chdir($tdir);
     361                    $tar->add_files("$o");
     362                } else {
     363                    # It's in the common place instead
     364                    foreach my $c (keys $cb->{'commondir'}) {
     365                        if (-r "$dest/$c/$o") {
     366                            pb_log(1,"INFO: Adding to the tar file $dest/$c/$o\n");
     367                            chdir("$dest/$c");
     368                            $tar->add_files("$o");
     369                        }
     370                    }
     371                }
    360372                # Add an entry to the DB
    361373                if (defined $dbid->{$o}) {
     
    397409$ssh2 = cb_ssh_init($remote,$mach,$debug);
    398410
    399 $ssh2->scp_put($tarfile,$tarfile);
     411if (!($ssh2->scp_put($tarfile,$tarfile))) {
     412    my @error = $ssh2->error();
     413    print "@error\n";
     414    confess "Unable to copy tar file $tarfile to $mach\n";
     415}
    400416pb_log(0,"INFO: Copying content under $ENV{'PBTMP'} on $remote\@$mach\n");
    401417
     
    404420if ((defined $cb->{'commondir'}) && (defined $cb->{'commondir'}->{$machine})) {
    405421    $path = $cb->{'webdir'}->{$machine};
    406     $tbextract = $cb->{'commondir'}->{$machine};
     422    #$tbextract = $cb->{'commondir'}->{$machine};
    407423}
    408424$chan = $ssh2->channel();
     
    410426
    411427if (not $debug) {
     428    # Reminder: sudo should be configured for this account as Defaults !requiretty for this to work
    412429    print $chan "sudo tar -C $path -x -f $tarfile $tbextract\n";
    413430    pb_log(0,"WARNING: $_\n") while (<$chan>);
     
    440457    if (defined $cbp->{$k}->{'reloadscript'}) {
    441458        if (not $debug) {
    442             print $chan "$cbp->{$k}->{'reloadscript'}\n";
     459            print $chan "sudo $cbp->{$k}->{'reloadscript'}\n";
    443460        }
    444         pb_log(0,"INFO: Executing (on $mach) $cbp->{$k}->{'reloadscript'}\n");
    445     }
     461        pb_log(0,"INFO: Executing (on $mach) $cbp->{$k}->{'reloadscript'} as root\n");
     462    }
     463}
     464
     465pb_log(0,"INFO: Executing (on $mach) /usr/local/bin/mk$mach if present as root\n");
     466if (not $debug) {
     467        # Using Net::SSH2 here was not working (due to the shell ?)
     468        pb_system("ssh $remote\@$mach \"sudo /usr/local/bin/mk$mach\"","WAIT: Executing (on $mach) /usr/local/bin/mk$mach if present as root","verbose");
    446469}
    447470
     
    450473    print $chan "rm -rf $ENV{'PBTMP'}\n";
    451474} else {
    452     pb_log(1,"Remove remote directory $ENV{'PBTMP'} on $mach\n");
     475    pb_log(1,"INFO: Please remove remote directory $ENV{'PBTMP'} on $mach\n");
    453476}
    454477$chan->close();
  • projects/casparbuster/devel/lib/CasparBuster/SSH.pm

    r1667 r1683  
    6363pb_log(3,"DEBUG: New SSH2 object created\n");
    6464$ssh2->debug(1) if ($debug > 2);
    65 pb_log(3,"DEBUG: SSH2 debug mode on\n");
     65pb_log(3,"DEBUG: SSH2 debug mode on\n") if ($debug > 2);
    6666
    6767$ssh2->connect($machine) || confess "Unable to connect to $remote\@$machine: $!";
     
    7777
    7878$chan->exec("mkdir -p $ENV{'PBTMP'}");
    79 pb_log(3,"DEBUG: Created $ENV{'PBTMP'} on $remote\@$machine\n");
     79pb_log(1,"DEBUG: Created $ENV{'PBTMP'} on $remote\@$machine\n");
    8080$chan->close;
    8181
Note: See TracChangeset for help on using the changeset viewer.