Changeset 354 in ProjectBuilder for devel/pb/bin
- Timestamp:
- Apr 5, 2008, 12:14:28 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r353 r354 1229 1229 # Do not use the one passed potentially with -a 1230 1230 my ($pbac) = pb_conf_get($vtype."login"); 1231 my ($key,$zero0,$zero1,$zero2); 1231 1232 1232 1233 if ($vtype eq "vm") { … … 1244 1245 return if (($vmpid == 0) && ($vmexist == 0)); 1245 1246 1247 # Store the pub key part in a variable 1248 open(FILE,"$keyfile.pub") || die "Unable to open $keyfile.pub"; 1249 ($zero0,$zero1,$zero2) = split(/ /,<FILE>); 1250 close(FILE); 1251 1252 $key = "\Q$zero1"; 1253 1246 1254 pb_system("cat $keyfile.pub | ssh -q -p $nport -i $keyfile root\@$vmhost->{$ENV{'PBPROJ'}} \"mkdir -p .ssh ; chmod 700 .ssh ; cat >> .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys\"","Copying local keys to $vtype. This will require the root password"); 1247 1255 # once this is done, we can do what we want on the VM remotely … … 1258 1266 use File::Copy; 1259 1267 1268 EOF 1269 if ($vtype eq "vm") { 1270 print SCRIPT << 'EOF'; 1271 # Removes duplicate in .ssh/authorized_keys of our key if needed 1272 # 1273 my $file1="$ENV{'HOME'}/.ssh/authorized_keys"; 1274 open(PBFILE,$file1) || die "Unable to open $file1"; 1275 open(PBOUT,"> $file1.new") || die "Unable to open $file1.new"; 1276 my $count = 0; 1277 while (<PBFILE>) { 1278 EOF 1279 print SCRIPT << "EOF"; 1280 if (/ $key /) { 1281 \$count++; 1282 } 1283 print PBOUT \$_ if ((\$count <= 1) || (\$_ !~ / $key /)); 1284 } 1285 close(PBFILE); 1286 close(PBOUT); 1287 rename("\$file1.new",\$file1); 1288 chmod 0600,\$file1; 1289 EOF 1290 } 1291 print SCRIPT << 'EOF'; 1292 1293 # Adds $pbac->{$ENV{'PBPROJ'}} as an account if needed 1294 # 1260 1295 my $file="/etc/passwd"; 1261 1296 open(PBFILE,$file) || die "Unable to open $file"; … … 1279 1314 system "useradd $pbac->{$ENV{'PBPROJ'}} -g $pbac->{$ENV{'PBPROJ'}} -m -d /home/$pbac->{$ENV{'PBPROJ'}}"; 1280 1315 1281 # For pb 1316 # allow ssh entry to build 1317 # 1282 1318 chdir "/home/$pbac->{$ENV{'PBPROJ'}}"; 1283 1319 mkdir ".ssh",0700;
Note:
See TracChangeset
for help on using the changeset viewer.