#!/usr/bin/perl # do_install.cgi # Install some package on all hosts, in parallel. If the package was # downloaded from a URL, have the hosts do the same - otherwise, transfer # it to each. require './cluster-software-lib.pl'; &ReadParse(); # Work out package names, for display to use if ($in{'source'} == 3) { # Package names are from YUM @packages = @names = @descs = split(/\s+/, $in{'file'}); } else { # Get package names and descriptions from file @packages = $in{'unknownfile'} ? ( $in{'unknownfile'} ) : &software::file_packages($in{'file'}); foreach $p (@packages) { local ($n, $d) = split(/\s+/, $p, 2); push(@names, $n); push(@descs, $d || $n); } } $in{'source'} == 3 || -r $in{'file'} || &error($text{'do_edeleted'}); &ui_print_header(undef, $text{'do_title'}, ""); # Setup error handler for down hosts sub inst_error { $inst_error_msg = join("", @_); } &remote_error_setup(\&inst_error); # Work out hosts to install on @hosts = &list_software_hosts(); @already = grep { local ($alr) = grep { $_->{'name'} eq $names[0] } @{$_->{'packages'}}; $alr } @hosts; @hosts = &create_on_parse("do_header", \@already, join(" ", @names)); @servers = &list_servers(); $p = 0; foreach $h (@hosts) { # Install on one host local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers; local $d = $s->{'desc'} || $s->{'realhost'} || $s->{'host'}; local ($rh = "READ$p", $wh = "WRITE$p"); pipe($rh, $wh); select($wh); $| = 1; select(STDOUT); if (!fork()) { # Do the install in a subprocess close($rh); &remote_foreign_require($s->{'host'}, "software", "software-lib.pl"); if ($inst_error_msg) { # Failed to contact host .. print $wh &serialise_variable([ $inst_error_msg ]); exit; } local $rfile; local $need_unlink = 1; if ($in{'source'} == 3) { # Installing from an update service like APT or YUM $need_unlink = 0; } elsif (!$s->{'id'}) { # This host, so we already have the file $rfile = $in{'file'}; $need_unlink = 0; } elsif ($in{'source'} == 0) { # Is the file the same on remote (like if we have NFS) local @st = stat($in{'file'}); local $rst = &remote_eval($s->{'host'}, "software", "[ stat('$in{'file'}') ]"); local @rst = @$rst; if (@st && @rst && $st[7] == $rst[7] && $st[9] == $rst[9]) { # File is the same! No need to download $rfile = $in{'file'}; $need_unlink = 0; } else { # Need to copy the file across :( local $filename = $in{'file'}; $filename =~ /([^\/\\]+)$/; $rfile = &remote_write( $s->{'host'}, $in{'file'}, undef, "$1"); } } elsif ($in{'source'} == 2 && $in{'down'}) { # Ask the remote server to download the file local $filename = $in{'file'}; $filename =~ /([^\/\\]+$)/; $rfile = &remote_foreign_call($s->{'host'}, "software", "tempname", $1); if ($in{'ftpfile'}) { &remote_foreign_call($s->{'host'}, "software", "ftp_download", $in{'host'}, $in{'ftpfile'}, $rfile); } else { &remote_foreign_call($s->{'host'}, "software", "http_download", $in{'host'}, $in{'port'}, $in{'page'}, $rfile, undef, undef, $in{'ssl'}); } } else { # Need to copy the file across :( local $filename = $in{'file'}; $filename =~ /([^\/\\]+)$/; $rfile = &remote_write($s->{'host'}, $in{'file'}, undef, "$1"); } # Do the install .. local @rv; if ($in{'source'} != 3) { # Installing some package for($i=0; $i<@names; $i++) { local $error = &remote_foreign_call( $s->{'host'}, "software", "install_package", $rfile, $names[$i], \%in); if ($error) { push(@rv, $error); } else { # Success .. get the package details push(@rv, [ &remote_foreign_call($s->{'host'}, "software", "package_info", $names[$i]) ] ); } } } else { # Install from update system local $rus = &remote_eval($s->{'host'}, "software", '$update_system'); if ($rus ne $software::update_system) { push(@rv, &text('install_erus', $rus, $software::update_system)); } else { local @resp = &remote_foreign_call($s->{'host'}, "software", "capture_function_output", "software::update_system_install", $in{'file'}); if (@{$resp[1]}) { # Worked .. get package details foreach $p (@{$resp[1]}) { push(@rv, [ &remote_foreign_call($s->{'host'}, "software", "package_info", $p) ] ); } } else { # May have failed ($first) = split(/\s+/, $in{'file'}); local @info = &remote_foreign_call( $s->{'host'}, "software", "package_info", $first); if (@info && $info[0] eq $first) { push(@rv, &text('install_ealready', $info[4])); } else { push(@rv, $text{'install_eupdate'}); } } } } &remote_eval($s->{'host'}, "software", "unlink('$rfile')") if ($need_unlink); print $wh &serialise_variable(\@rv); close($wh); exit; } close($wh); $p++; } # Get back all the results $p = 0; foreach $h (@hosts) { local $rh = "READ$p"; local $line = <$rh>; close($rh); local $rv = &unserialise_variable($line); local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers; local $d = $s->{'desc'} || $s->{'realhost'} || $s->{'host'}; if (!$line) { print &text('do_failed', $d, "Unknown reason"),"<br>\n"; } else { $i=0; foreach $r (@$rv) { if (ref($r)) { # Install went ok! print &text('do_success2', $r->[0],$d),"<br>\n"; $pinfo[$i] = $r if (!$pinfo[$i] && @$r); if (!@$r) { # Failed to get info! Need a refresh.. $refresh{$s->{'id'}} = 1; } elsif ($names[$i] && &indexof($names[$i], @{$h->{'packages'}}) < 0) { push(@{$h->{'packages'}}, { 'name' => $names[$i], 'desc' => $descs[$i], 'class' => $pinfo[$i]->[1], 'version' => $pinfo[$i]->[4] }); &save_software_host($h); } } else { # Failed for some reason.. print &text('do_failed', $d, $r),"<br>\n"; } $i++; } } $p++; } unlink($in{'file'}) if ($in{'need_unlink'}); print "<p><b>$text{'do_done'}</b><p>\n"; # Show details of installed packages, where we have them for($i=0; $i<@names; $i++) { next if (!$pinfo[$i]); print "<table border width=100%>\n"; print "<tr $tb> <td><b>$text{'do_details'}</b></td> </tr>\n"; print "<tr $cb> <td><table width=100%>\n"; if ($pinfo[$i]->[2]) { print "<tr> <td valign=top width=20%><b>$text{'do_desc'}</b></td>\n"; print "<td colspan=3><pre>$pinfo[$i]->[2]</pre></td> </tr>\n"; } print "<tr> <td width=20%><b>$text{'do_pack'}</b></td> <td>$pinfo[$i]->[0]</td>\n"; print "<td width=20%><b>$text{'do_class'}</b></td> <td>", $pinfo[$i]->[1] ? $pinfo[$i]->[1] : $text{'do_none'},"</td> </tr>\n"; print "<tr> <td width=20%><b>$text{'do_ver'}</b></td> <td>$pinfo[$i]->[4]</td>\n"; print "<td width=20%><b>$text{'do_vend'}</b></td> <td>$pinfo[$i]->[5]</td> </tr>\n"; print "<tr> <td width=20%><b>$text{'do_arch'}</b></td> <td>$pinfo[$i]->[3]</td>\n"; print "<td width=20%><b>$text{'do_inst'}</b></td> <td>$pinfo[$i]->[6]</td> </tr>\n"; print "</table></td></tr></table><p>\n"; } &remote_finished(); &ui_print_footer("", $text{'index_return'});
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
help | Folder | 0755 |
|
|
images | Folder | 0755 |
|
|
lang | Folder | 0755 |
|
|
CHANGELOG | File | 1.01 KB | 0644 |
|
add.cgi | File | 904 B | 0755 |
|
close.cgi | File | 272 B | 0755 |
|
closeall.cgi | File | 179 B | 0755 |
|
cluster-software-lib.pl | File | 9.51 KB | 0755 |
|
compare.cgi | File | 1.81 KB | 0755 |
|
compare_form.cgi | File | 1.13 KB | 0755 |
|
config | File | 25 B | 0644 |
|
config.info | File | 108 B | 0644 |
|
config.info.ca | File | 133 B | 0644 |
|
config.info.cs | File | 82 B | 0644 |
|
config.info.de | File | 125 B | 0644 |
|
config.info.es | File | 90 B | 0644 |
|
config.info.fr | File | 134 B | 0644 |
|
config.info.hr | File | 0 B | 0644 |
|
config.info.ms | File | 131 B | 0644 |
|
config.info.nl | File | 130 B | 0644 |
|
config.info.no | File | 129 B | 0644 |
|
config.info.pl | File | 121 B | 0644 |
|
defaultacl | File | 6 B | 0644 |
|
delete_host.cgi | File | 254 B | 0755 |
|
delete_pack.cgi | File | 3.15 KB | 0755 |
|
delete_packs.cgi | File | 2.86 KB | 0755 |
|
do_install.cgi | File | 7.11 KB | 0755 |
|
do_install_serial.cgi | File | 3.55 KB | 0755 |
|
edit_host.cgi | File | 3.84 KB | 0755 |
|
edit_pack.cgi | File | 3.33 KB | 0755 |
|
index.cgi | File | 4.87 KB | 0755 |
|
install_pack.cgi | File | 4.82 KB | 0755 |
|
list_pack.cgi | File | 2.28 KB | 0755 |
|
module.info | File | 427 B | 0644 |
|
module.info.af | File | 0 B | 0644 |
|
module.info.af.auto | File | 154 B | 0644 |
|
module.info.ar | File | 0 B | 0644 |
|
module.info.ar.auto | File | 201 B | 0644 |
|
module.info.be | File | 0 B | 0644 |
|
module.info.be.auto | File | 282 B | 0644 |
|
module.info.bg | File | 0 B | 0644 |
|
module.info.bg.auto | File | 251 B | 0644 |
|
module.info.ca | File | 155 B | 0644 |
|
module.info.ca.auto | File | 31 B | 0644 |
|
module.info.cs | File | 40 B | 0644 |
|
module.info.cs.auto | File | 122 B | 0644 |
|
module.info.da | File | 0 B | 0644 |
|
module.info.da.auto | File | 153 B | 0644 |
|
module.info.de | File | 133 B | 0644 |
|
module.info.de.auto | File | 25 B | 0644 |
|
module.info.el | File | 0 B | 0644 |
|
module.info.el.auto | File | 263 B | 0644 |
|
module.info.es | File | 39 B | 0644 |
|
module.info.es.auto | File | 119 B | 0644 |
|
module.info.eu | File | 0 B | 0644 |
|
module.info.eu.auto | File | 141 B | 0644 |
|
module.info.fa | File | 0 B | 0644 |
|
module.info.fa.auto | File | 228 B | 0644 |
|
module.info.fi | File | 0 B | 0644 |
|
module.info.fi.auto | File | 156 B | 0644 |
|
module.info.fr | File | 41 B | 0644 |
|
module.info.fr.auto | File | 139 B | 0644 |
|
module.info.he | File | 0 B | 0644 |
|
module.info.he.auto | File | 186 B | 0644 |
|
module.info.hr | File | 0 B | 0644 |
|
module.info.hr.auto | File | 155 B | 0644 |
|
module.info.hu | File | 33 B | 0644 |
|
module.info.hu.auto | File | 125 B | 0644 |
|
module.info.it | File | 0 B | 0644 |
|
module.info.it.auto | File | 147 B | 0644 |
|
module.info.ja | File | 0 B | 0644 |
|
module.info.ja.auto | File | 228 B | 0644 |
|
module.info.ko | File | 0 B | 0644 |
|
module.info.ko.auto | File | 193 B | 0644 |
|
module.info.lt | File | 0 B | 0644 |
|
module.info.lt.auto | File | 181 B | 0644 |
|
module.info.lv | File | 0 B | 0644 |
|
module.info.lv.auto | File | 165 B | 0644 |
|
module.info.ms | File | 119 B | 0644 |
|
module.info.ms.auto | File | 25 B | 0644 |
|
module.info.mt | File | 0 B | 0644 |
|
module.info.mt.auto | File | 158 B | 0644 |
|
module.info.nl | File | 35 B | 0644 |
|
module.info.nl.auto | File | 122 B | 0644 |
|
module.info.no | File | 35 B | 0644 |
|
module.info.no.auto | File | 115 B | 0644 |
|
module.info.pl | File | 132 B | 0644 |
|
module.info.pl.auto | File | 33 B | 0644 |
|
module.info.pt | File | 0 B | 0644 |
|
module.info.pt.auto | File | 154 B | 0644 |
|
module.info.pt_BR | File | 0 B | 0644 |
|
module.info.pt_BR.auto | File | 163 B | 0644 |
|
module.info.ro | File | 0 B | 0644 |
|
module.info.ro.auto | File | 152 B | 0644 |
|
module.info.ru | File | 0 B | 0644 |
|
module.info.ru.auto | File | 278 B | 0644 |
|
module.info.sk | File | 0 B | 0644 |
|
module.info.sk.auto | File | 162 B | 0644 |
|
module.info.sl | File | 0 B | 0644 |
|
module.info.sl.auto | File | 159 B | 0644 |
|
module.info.sv | File | 0 B | 0644 |
|
module.info.sv.auto | File | 151 B | 0644 |
|
module.info.th | File | 0 B | 0644 |
|
module.info.th.auto | File | 351 B | 0644 |
|
module.info.tr | File | 0 B | 0644 |
|
module.info.tr.auto | File | 159 B | 0644 |
|
module.info.uk | File | 0 B | 0644 |
|
module.info.uk.auto | File | 272 B | 0644 |
|
module.info.ur | File | 0 B | 0644 |
|
module.info.ur.auto | File | 235 B | 0644 |
|
module.info.vi | File | 0 B | 0644 |
|
module.info.vi.auto | File | 162 B | 0644 |
|
module.info.zh | File | 0 B | 0644 |
|
module.info.zh.auto | File | 131 B | 0644 |
|
module.info.zh_TW | File | 0 B | 0644 |
|
module.info.zh_TW.auto | File | 140 B | 0644 |
|
open.cgi | File | 250 B | 0755 |
|
openall.cgi | File | 427 B | 0755 |
|
prefs.info | File | 28 B | 0644 |
|
refresh.cgi | File | 1.61 KB | 0755 |
|
search.cgi | File | 1.92 KB | 0755 |
|