3 # Install some package on all hosts, in parallel. If the package was
4 # downloaded from a URL, have the hosts do the same - otherwise, transfer
7 require './cluster-software-lib.pl';
9 @packages = &foreign_call("software", "file_packages", $in{'file'});
10 foreach $p (@packages) {
11 local ($n, $d) = split(/\s+/, $p, 2);
12 push(@names, $n); push(@descs, $d);
14 -r $in{'file'} || &error($text{'do_edeleted'});
15 &ui_print_header(undef, $text{'do_title'}, "");
16 print "<b>",&text('do_header', join(" ", @names)),"</b><p>\n";
18 @hosts = &list_software_hosts();
19 @servers = &list_servers();
21 # Check if already installed
22 local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
23 local $d = $s->{'desc'} ? $s->{'desc'} : $s->{'host'};
24 local ($a) = grep { &indexof($_->{'name'}, @names) >= 0 }
27 # print &text('do_already', $d),"<br>\n";
31 &remote_foreign_require($s->{'host'}, "software", "software-lib.pl");
33 local $need_unlink = 1;
35 # This host, so we already have the file
39 elsif ($in{'source'} == 2 && $in{'down'}) {
40 # Ask the remote server to download the file
41 $rfile = &remote_eval($s->{'host'}, "software", '&tempname()');
43 &remote_foreign_call($s->{'host'}, "software",
44 "ftp_download", $in{'host'}, $in{'ftpfile'},
48 &remote_foreign_call($s->{'host'}, "software",
49 "http_download", $in{'host'}, $in{'port'},
54 # Need to copy the file across :(
55 $rfile = &remote_write($s->{'host'}, $in{'file'});
59 for($i=0; $i<@names; $i++) {
60 local $error = &remote_foreign_call($s->{'host'}, "software",
61 "install_package", $rfile, $names[$i], \%in);
63 print &text('do_failed', $d, $error),"<br>\n";
66 # Success .. get the package details and add to list
67 print &text('do_success', $d),"<br>\n";
69 $pinfo[$i] = [ &remote_foreign_call($s->{'host'}, "software",
70 "package_info", $names[$i]) ];
72 if (&indexof($names[$i], @{$h->{'packages'}}) < 0) {
73 push(@{$h->{'packages'}},
74 { 'name' => $names[$i],
76 'class' => $pinfo[$i]->[1] });
77 &save_software_host($h);
81 &remote_eval($s->{'host'}, "software", "unlink('$rfile')") if ($need_unlink);
83 unlink($in{'file'}) if ($in{'need_unlink'});
84 print "<p><b>$text{'do_done'}</b><p>\n";
86 for($i=0; $i<@names; $i++) {
87 next if (!$pinfo[$i]);
88 print "<table border width=100%>\n";
89 print "<tr $tb> <td><b>$text{'do_details'}</b></td> </tr>\n";
90 print "<tr $cb> <td><table width=100%>\n";
91 print "<tr> <td valign=top width=20%><b>$text{'do_desc'}</b></td>\n";
92 print "<td colspan=3><font size=+1><pre>$pinfo[$i]->[2]</pre></font></td> </tr>\n";
94 print "<tr> <td width=20%><b>$text{'do_pack'}</b></td> <td>$pinfo[$i]->[0]</td>\n";
95 print "<td width=20%><b>$text{'do_class'}</b></td> <td>",
96 $pinfo[$i]->[1] ? $pinfo[$i]->[1] : $text{'do_none'},"</td> </tr>\n";
98 print "<tr> <td width=20%><b>$text{'do_ver'}</b></td> <td>$pinfo[$i]->[4]</td>\n";
99 print "<td width=20%><b>$text{'do_vend'}</b></td> <td>$pinfo[$i]->[5]</td> </tr>\n";
101 print "<tr> <td width=20%><b>$text{'do_arch'}</b></td> <td>$pinfo[$i]->[3]</td>\n";
102 print "<td width=20%><b>$text{'do_inst'}</b></td> <td>$pinfo[$i]->[6]</td> </tr>\n";
103 print "</table></td></tr></table><p>\n";
107 &ui_print_footer("", $text{'index_return'});