Changeset 348 in ProjectBuilder for devel/pb/bin
- Timestamp:
- Apr 3, 2008, 2:23:49 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r347 r348 337 337 if (defined $opts{'l'}) { 338 338 open(LOG,"> $opts{'l'}") || die "Unable to log to $opts{'l'}: $!"; 339 $LOG = *LOG;339 $LOG = \*LOG; 340 340 $debug = 0 if ($debug == -1); 341 341 } … … 433 433 } elsif ($action =~ /^setupve$/) { 434 434 my $pbscript = pb_setup_v("ve"); 435 # That buil script needs to be run as root 436 $pbaccount = "root"; 435 437 pb_script2v($pbscript,"ve"); 436 438 } elsif ($action =~ /^setupvm$/) { 437 439 my $pbscript = pb_setup_v("vm"); 440 # That buil script needs to be run as root 441 $pbaccount = "root"; 438 442 pb_script2v($pbscript,"vm"); 439 443 } elsif ($action =~ /^newproj$/) { … … 792 796 my $conf = "sshconf"; 793 797 my $rebuild = "sshrebuild"; 794 if ( $cmt eq "vm") {798 if (($cmt eq "vm") || ($cmt eq "Script")) { 795 799 $login = "vmlogin"; 796 800 $dir = "pbdefdir"; … … 1251 1255 my $keyfile = pb_ssh_get(1); 1252 1256 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'}}; 1255 1259 $nport = "$pbport" if (defined $pbport); 1256 1260 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"); 1258 1262 # once this is done, we can do what we want on the VM remotely 1259 1263 } … … 1274 1278 while (<PBFILE>) { 1275 1279 EOF 1276 print SCRIPT << "EOF" 1280 print SCRIPT << "EOF"; 1277 1281 \$found = 1 if (/^$pbaccount:/); 1278 1282 EOF … … 1286 1290 } 1287 1291 EOF 1288 print SCRIPT << "EOF" 1292 print SCRIPT << "EOF"; 1289 1293 system "groupadd $pbaccount"; 1290 1294 system "useradd $pbaccount -g $pbaccount -m -d /home/$pbaccount"; … … 1294 1298 mkdir ".ssh",0700; 1295 1299 # Allow those accessing root to access the build account 1296 copy("\$ HOME/.ssh/authorized_keys",".ssh/authorized_keys");1300 copy("\$ENV{'HOME'}/.ssh/authorized_keys",".ssh/authorized_keys"); 1297 1301 chmod 0600,".ssh/authorized_keys"; 1298 1302 system 'chown -R $pbaccount:$pbaccount .ssh'; … … 1308 1312 while (<PBFILE>) { 1309 1313 EOF 1310 print SCRIPT << "EOF" 1314 print SCRIPT << "EOF"; 1311 1315 s/^$pbaccount:\!\!:/$pbaccount:*:/; 1312 1316 s/^$pbaccount:\!:/$pbaccount:*:/; #SLES 9 e.g. 1313 1317 EOF 1314 print SCRIPT << 'EOF' 1318 print SCRIPT << 'EOF'; 1315 1319 print PBOUT $_; 1316 1320 } … … 1328 1332 while (<PBFILE>) { 1329 1333 EOF 1330 print SCRIPT << "EOF" 1334 print SCRIPT << "EOF"; 1331 1335 next if (/^$pbaccount /); 1332 1336 EOF 1333 print SCRIPT << 'EOF' 1337 print SCRIPT << 'EOF'; 1334 1338 s/Defaults[ \t]+requiretty//; 1335 1339 print PBOUT $_; … … 1337 1341 close(PBFILE); 1338 1342 EOF 1339 print SCRIPT << "EOF" 1343 print SCRIPT << "EOF"; 1340 1344 # This is needed in order to be able to halt the machine from the $pbaccount account at least 1341 1345 print PBOUT "$pbaccount ALL=(ALL) NOPASSWD:ALL\n"; 1342 1346 EOF 1343 print SCRIPT << 'EOF' 1347 print SCRIPT << 'EOF'; 1344 1348 close(PBOUT); 1345 1349 rename("$file.new",$file); … … 1348 1352 EOF 1349 1353 1350 pb_install_deps(SCRIPT); 1354 my $SCRIPT = \*SCRIPT; 1355 1356 pb_install_deps($SCRIPT); 1351 1357 1352 1358 print SCRIPT << 'EOF'; … … 1381 1387 sub pb_install_deps { 1382 1388 1383 my \*SCRIPT = shift;1384 1385 print SCRIPT<< 'EOF';1389 my $SCRIPT = shift; 1390 1391 print {$SCRIPT} << 'EOF'; 1386 1392 # We need to have that pb_distro_init function 1387 1393 # Get it from Project-Builder::Distribution … … 1437 1443 # We have specific keys by default 1438 1444 $keyfile = "$ENV{'HOME'}/.ssh/pb_dsa"; 1439 if ( (-s$keyfile) && ($create eq 1)) {1445 if (!(-e $keyfile) && ($create eq 1)) { 1440 1446 pb_system("ssh-keygen -q -b 1024 -N '' -f $keyfile -t dsa","Generating SSH keys for pb"); 1441 1447 }
Note:
See TracChangeset
for help on using the changeset viewer.