Changeset 2049 in ProjectBuilder for devel/pb/bin
- Timestamp:
- Feb 20, 2016, 8:31:42 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r2048 r2049 762 762 if (defined $opts{'s'}) { 763 763 $pbscript{'default'} = $opts{'s'}; 764 die "option -s requires a script having a full path name" if ($pbscript{'default'} !~ /^\//); 764 765 } 765 766 if (defined $opts{'a'}) { … … 1969 1970 1970 1971 my $cmt = shift; 1971 my $pbscript = shift;1972 my $pbscript1 = shift; 1972 1973 my $v = shift; 1973 1974 my $vexist = shift; # 0 is FALSE … … 2538 2539 $cptarget = "CPAN"; 2539 2540 } else { 2540 my $keyfile = pb_ssh_get(0,$mac,$nport);2541 2541 my $keyopt = ""; 2542 $keyopt = "-i $keyfile" if ((defined $keyfile) && ($cmt !~ /Packages/)); 2542 if ($cmt !~ /Packages/) { 2543 my $keyfile = pb_ssh_get(0,$remhost,$nport); 2544 $keyopt = "-i $keyfile" if (defined $keyfile); 2545 } 2543 2546 my $sshcmd = pb_check_req("ssh",1); 2544 2547 my $scpcmd = pb_check_req("scp",1); … … 2625 2628 2626 2629 # Use the right script name depending on context 2627 my $pbscript 1;2630 my $pbscript2; 2628 2631 if (($cmt =~ /^(V[EM]|RM)/) || ($cmt =~ /Packages/)){ 2629 $pbscript 1= $pbscript{$v};2632 $pbscript2 = $pbscript{$v}; 2630 2633 } else { 2631 $pbscript 1= "pbscript";2634 $pbscript2 = "pbscript"; 2632 2635 } 2633 2636 … … 2637 2640 if ($cmt ne "CPAN") { 2638 2641 if (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep < 3)) { 2639 copy("$pbscript 1","$context");2640 my $s = basename($pbscript 1);2642 copy("$pbscript2","$context"); 2643 my $s = basename($pbscript2); 2641 2644 print DOCKER "COPY $s $cptarget/\n"; 2642 2645 # call directly with perl to avoid text file busy error messages … … 2646 2649 close(DOCKER); 2647 2650 } elsif (($cmt =~ /^VE/) && ($vetype eq "docker") && ($pbstep >= 3)) { 2648 $dkcmd = "/bin/bash $homedir/$tdir-2/".basename($pbscript 1);2651 $dkcmd = "/bin/bash $homedir/$tdir-2/".basename($pbscript2); 2649 2652 } else { 2650 my $s = basename($pbscript 1);2653 my $s = basename($pbscript2); 2651 2654 $shcmd .= " \"echo \'cd $tdir ; if [ -x $s ]; then ./$s; fi ; if [ $pbkeep == 0 ]; then rm -f $s; fi\' | bash\""; 2652 2655 } … … 2666 2669 $tsrc .= " ".basename($f); 2667 2670 } 2668 my $ts = "$ENV{'PBTMP'}/vebuild/".basename($pbscript 1);2671 my $ts = "$ENV{'PBTMP'}/vebuild/".basename($pbscript2); 2669 2672 open(DOCKER," > $ts") || confess "Unable to create $ts"; 2670 2673 print DOCKER "#!/bin/bash\n"; … … 2677 2680 print DOCKER "done\n"; 2678 2681 print DOCKER "(cd $homedir/$tdir-2 ; ls -al)\n"; 2679 print DOCKER pb_get_content($pbscript 1);2682 print DOCKER pb_get_content($pbscript2); 2680 2683 print DOCKER "\n# Get content back from guest in a host dir\n"; 2681 2684 # Host dir seen as TDIR in container … … 2747 2750 } 2748 2751 } 2749 unlink("$pbscript{$v}") if ((($cmt =~ /^(V[ME]|RM)/) || ($cmt =~ /Packages/)) && ($pbkeep eq 0) );2752 unlink("$pbscript{$v}") if ((($cmt =~ /^(V[ME]|RM)/) || ($cmt =~ /Packages/)) && ($pbkeep eq 0) && ($cmt !~ /Script/)); 2750 2753 2751 2754 pb_log(2,"Before halt, vexist: $vexist, vpid: $vpid\n"); … … 2810 2813 2811 2814 pb_log(2,"DEBUG: pb_script2v($vtype,$pbstep,$pbforce,$snapme)\n"); 2812 pb_log(2,"DEBUG: pb_script2v(pbscript: ".Dumper($pbscript)."\n") ;2815 pb_log(2,"DEBUG: pb_script2v(pbscript: ".Dumper($pbscript)."\n") if (defined $pbscript); 2813 2816 pb_parallel_launchv($pbscript,$vtype,uc($vtype)."Script",$pbstep,$pbimage,$pbforce,$snapme,$pbsnap); 2814 2817 } … … 2867 2870 $pm->start($counter) and next if (defined $pbparallel); 2868 2871 2872 # If launched via script2v then get the script passed as the one for the that VM 2873 if (not defined $pbscript->{$v}) { 2874 $pbscript->{$v} = $pbscript->{'default'}; 2875 } 2876 # 2869 2877 # Launch a single operation 2870 my $pbscript = $pbscript->{$v} if (defined $pbscript->{$v}); 2871 $pbscript = $pbscript->{'default'} if (not defined $pbscript); 2872 ($vexist,$vpid) = pb_launchv($pbscript,$vtype,$v,$action,$pbstep,$pbforce,$snapme,$pbsnap,$pbimage); 2878 ($vexist,$vpid) = pb_launchv($pbscript->{$v},$vtype,$v,$action,$pbstep,$pbforce,$snapme,$pbsnap,$pbimage); 2873 2879 2874 2880 # Skip that VM/RM if something went wrong … … 2887 2893 sub pb_launchv { 2888 2894 2889 my $pbscript =shift;2895 my $pbscript1=shift; # Just the script name to execute, not the hash 2890 2896 my $vtype = shift; 2891 2897 my $v = shift; # Only 1 VM/VE/RM treated here … … 2913 2919 pb_log(2,"DEBUG: pb_launchv(vtype,v,step,force,snapme,usesnap: $vtype,$v,$pbstep,$pbforce,$snapme,$usesnap)\n"); 2914 2920 pb_log(2,"DEBUG: pb_launchv(pbimage: $pbimage)\n") if (defined $pbimage); 2915 pb_log(2,"DEBUG: pb_launchv(pb image: $pbscript)\n") if (defined $pbscript);2921 pb_log(2,"DEBUG: pb_launchv(pbscript $pbscript1)\n") if (defined $pbscript1); 2916 2922 pb_log(2,"DEBUG: pb_launchv(action: $action)\n") if (defined $action); 2917 2923 # Keep only the first VM in case many were given … … 3098 3104 if (defined $action) { 3099 3105 pb_log(2,"DEBUG: Before send2target, vexist: $vexist, vpid: $vpid, vtype: $vtype, v: $v, action: $action\n"); 3100 pb_send2target($action,$pbscript ,$v,$vexist,$vpid,$snapme,$pbstep);3106 pb_send2target($action,$pbscript1,$v,$vexist,$vpid,$snapme,$pbstep); 3101 3107 } 3102 3108 return($vexist,$vpid); … … 4474 4480 sub pb_ssh_get { 4475 4481 4476 my $create = shift || 0; # Do not create keys by default 4482 my $create = shift || 0; # Do not create keys by default. In that case prefer native keys, not pb's ones 4477 4483 my $target = shift || "localhost"; 4478 4484 my $nport = shift || "22"; … … 4491 4497 while(<SCAN>) { 4492 4498 $ecdsa = 1 if ($_ =~ /ecdsa-/); 4499 pb_log(2,"Found ECDSA support on $target ($nport)\n"); 4493 4500 } 4494 4501 close(SCAN); … … 4497 4504 while(<SCAN>) { 4498 4505 $dsa = 1 if ($_ =~ /dsa-/); 4506 pb_log(2,"Found DSA support on $target ($nport)\n"); 4499 4507 } 4500 4508 close(SCAN); … … 4512 4520 # We still favoud DSA and fall back to ECDSA if not available 4513 4521 if ($dsa != 0) { 4514 $keyfile = "$ENV{'HOME'}/.ssh/id_dsa" if (-s "$ENV{'HOME'}/.ssh/id_dsa") ;4515 # And we favour a specific key over a generic one4522 # And we favour a specific key over a generic one except if in delivery to ftp server 4523 $keyfile = "$ENV{'HOME'}/.ssh/id_dsa" if ((-s "$ENV{'HOME'}/.ssh/id_dsa") && ($create eq 0)); 4516 4524 $keyfile = "$ENV{'HOME'}/.ssh/pb_dsa" if (-s "$ENV{'HOME'}/.ssh/pb_dsa"); 4517 4525 } else { 4518 $keyfile = "$ENV{'HOME'}/.ssh/id_ecdsa" if ((-s "$ENV{'HOME'}/.ssh/id_ecdsa") && ($ecdsa != 0));4519 # And we favour a specific key over a generic one4526 # And we favour a specific key over a generic one except if in delivery to ftp server 4527 $keyfile = "$ENV{'HOME'}/.ssh/id_ecdsa" if ((-s "$ENV{'HOME'}/.ssh/id_ecdsa") && ($ecdsa != 0) && ($create eq 0)); 4520 4528 $keyfile = "$ENV{'HOME'}/.ssh/pb_ecdsa" if ((-s "$ENV{'HOME'}/.ssh/pb_ecdsa") && ($ecdsa != 0)); 4521 4529 } 4522 4530 die "Unable to find your public ssh key under $ENV{'HOME'}/.ssh" if (not defined $keyfile); 4531 pb_log(2,"Using ssh key file $keyfile\n"); 4523 4532 return($keyfile); 4524 4533 } … … 4934 4943 my $vmhost; 4935 4944 4945 pb_log(1,"Entering pb_ssh_setup\n"); 4936 4946 ($vmhost) = pb_conf_get($vtype."host"); 4937 4947 # Prepare the key to be used and transfered remotely
Note:
See TracChangeset
for help on using the changeset viewer.