Changeset 348 in ProjectBuilder


Ignore:
Timestamp:
Apr 3, 2008, 2:23:49 AM (16 years ago)
Author:
Bruno Cornec
Message:
  • setupvm structure OK
  • Fix "Script" target
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r347 r348  
    337337if (defined $opts{'l'}) {
    338338    open(LOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!";
    339     $LOG = *LOG;
     339    $LOG = \*LOG;
    340340    $debug = 0  if ($debug == -1);
    341341    }
     
    433433} elsif ($action =~ /^setupve$/) {
    434434    my $pbscript = pb_setup_v("ve");
     435    # That buil script needs to be run as root
     436    $pbaccount = "root";
    435437    pb_script2v($pbscript,"ve");
    436438} elsif ($action =~ /^setupvm$/) {
    437439    my $pbscript = pb_setup_v("vm");
     440    # That buil script needs to be run as root
     441    $pbaccount = "root";
    438442    pb_script2v($pbscript,"vm");
    439443} elsif ($action =~ /^newproj$/) {
     
    792796    my $conf = "sshconf";
    793797    my $rebuild = "sshrebuild";
    794     if ($cmt eq "vm") {
     798    if (($cmt eq "vm") || ($cmt eq "Script")) {
    795799        $login = "vmlogin";
    796800        $dir = "pbdefdir";
     
    12511255    my $keyfile = pb_ssh_get(1);
    12521256   
    1253     my ($sshhost,$sshport) = pb_conf_get("vmhost","vmport");
    1254     my $nport = $sshport->{$ENV{'PBPROJ'}};
     1257    my ($vmhost,$vmport) = pb_conf_get("vmhost","vmport");
     1258    my $nport = $vmport->{$ENV{'PBPROJ'}};
    12551259    $nport = "$pbport" if (defined $pbport);
    12561260
    1257     pb_system("cat $keyfile.pub | ssh -q -p $nport -i $keyfile root\@$sshhost->{$ENV{'PBPROJ'}} \"mkdir .ssh ; chmod 700 .ssh ; cat > .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys\"","Copying local keys to $vtype. This will require the root password");
     1261    pb_system("cat $keyfile.pub | ssh -q -p $nport -i $keyfile root\@$vmhost->{$ENV{'PBPROJ'}} \"mkdir .ssh ; chmod 700 .ssh ; cat > .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys\"","Copying local keys to $vtype. This will require the root password");
    12581262    # once this is done, we can do what we want on the VM remotely
    12591263}
     
    12741278while (<PBFILE>) {
    12751279EOF
    1276 print SCRIPT << "EOF"
     1280print SCRIPT << "EOF";
    12771281    \$found = 1 if (/^$pbaccount:/);
    12781282EOF
     
    12861290    }
    12871291EOF
    1288 print SCRIPT << "EOF"
     1292print SCRIPT << "EOF";
    12891293system "groupadd $pbaccount";
    12901294system "useradd $pbaccount -g $pbaccount -m -d /home/$pbaccount";
     
    12941298mkdir ".ssh",0700;
    12951299# Allow those accessing root to access the build account
    1296 copy("\$HOME/.ssh/authorized_keys",".ssh/authorized_keys");
     1300copy("\$ENV{'HOME'}/.ssh/authorized_keys",".ssh/authorized_keys");
    12971301chmod 0600,".ssh/authorized_keys";
    12981302system 'chown -R $pbaccount:$pbaccount .ssh';
     
    13081312while (<PBFILE>) {
    13091313EOF
    1310 print SCRIPT << "EOF"
     1314print SCRIPT << "EOF";
    13111315    s/^$pbaccount:\!\!:/$pbaccount:*:/;
    13121316    s/^$pbaccount:\!:/$pbaccount:*:/;   #SLES 9 e.g.
    13131317EOF
    1314 print SCRIPT << 'EOF'
     1318print SCRIPT << 'EOF';
    13151319    print PBOUT $_;
    13161320}
     
    13281332while (<PBFILE>) {
    13291333EOF
    1330 print SCRIPT << "EOF"
     1334print SCRIPT << "EOF";
    13311335    next if (/^$pbaccount   /);
    13321336EOF
    1333 print SCRIPT << 'EOF'
     1337print SCRIPT << 'EOF';
    13341338    s/Defaults[ \t]+requiretty//;
    13351339    print PBOUT $_;
     
    13371341close(PBFILE);
    13381342EOF
    1339 print SCRIPT << "EOF"
     1343print SCRIPT << "EOF";
    13401344# This is needed in order to be able to halt the machine from the $pbaccount account at least
    13411345print PBOUT "$pbaccount   ALL=(ALL) NOPASSWD:ALL\n";
    13421346EOF
    1343 print SCRIPT << 'EOF'
     1347print SCRIPT << 'EOF';
    13441348close(PBOUT);
    13451349rename("$file.new",$file);
     
    13481352EOF
    13491353
    1350 pb_install_deps(SCRIPT);
     1354my $SCRIPT = \*SCRIPT;
     1355
     1356pb_install_deps($SCRIPT);
    13511357
    13521358print SCRIPT << 'EOF';
     
    13811387sub pb_install_deps {
    13821388
    1383 my \*SCRIPT = shift;
    1384 
    1385 print SCRIPT << 'EOF';
     1389my $SCRIPT = shift;
     1390
     1391print {$SCRIPT} << 'EOF';
    13861392# We need to have that pb_distro_init function
    13871393# Get it from Project-Builder::Distribution
     
    14371443# We have specific keys by default
    14381444$keyfile = "$ENV{'HOME'}/.ssh/pb_dsa";
    1439 if ((-s $keyfile) && ($create eq 1)) {
     1445if (!(-e $keyfile) && ($create eq 1)) {
    14401446    pb_system("ssh-keygen -q -b 1024 -N '' -f $keyfile -t dsa","Generating SSH keys for pb");
    14411447}
Note: See TracChangeset for help on using the changeset viewer.