3 # Download and install needed updates on multiple servers
5 require './cluster-webmin-lib.pl';
6 &foreign_require("webmin", "webmin-lib.pl");
8 &error_setup($webmin::text{'update_err'});
10 # Fetch list of updates
11 ($updates, $host, $port, $page, $ssl) = &webmin::fetch_updates(
12 $in{'source'} == 0 ? $webmin::update_url : $in{'other'});
14 # Build list of selected hosts, and show them
15 @servers = &list_servers();
16 &ui_print_unbuffered_header(undef, $text{'update_title'}, "");
17 @hosts = &create_on_parse("update_header", undef, undef);
19 # Setup error handler for down hosts
22 $inst_error_msg = join("", @_);
24 &remote_error_setup(\&inst_error);
26 # Run the update, on all hosts in parallel
29 local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
30 $s || &error("Failed to find server for $h->{'id'}");
32 local ($rh = "READ$p", $wh = "WRITE$p");
34 select($wh); $| = 1; select(STDOUT);
36 # Do the install in a subprocess
39 &remote_foreign_require($s->{'host'}, "webmin",
41 if ($inst_error_msg) {
42 # Failed to contact host ..
43 print $wh &serialise_variable($inst_error_msg);
47 # Work out which modules are needed
49 local $bv = &remote_foreign_call(
50 $s->{'host'}, "webmin",
51 "get_webmin_base_version");
52 foreach $u (@$updates) {
53 local %minfo = &remote_foreign_call(
54 $s->{'host'}, "webmin",
55 "get_module_info", $u->[0]);
56 local %tinfo = %minfo ? () :
58 $s->{'host'}, "webmin",
59 "get_theme_info", $u->[0]);
60 local %info = %minfo ? %minfo : %tinfo;
61 next if (($u->[1] >= $bv + .01 ||
63 (!%info || $info{'longdesc'} || !$in{'third'}));
65 # Check if update is appropriate
67 if (!%info && !$in{'missing'}) {
68 push(@rv, &webmin::text('update_mmissing',
72 if (%info && $info{'version'} >= $u->[1]) {
73 push(@rv, &webmin::text('update_malready',
77 local $osinfo = { 'os_support' => $u->[3] };
78 if (!&check_os_support($osinfo)) {
79 push(@rv, &webmin::text('update_mos',
86 push(@rv, [ 0, @$u ]);
90 ($mhost, $mport, $mpage, $mssl) =
91 &parse_http_url($u->[2], $host, $port, $page, $ssl);
92 $mtemp = &remote_foreign_call(
93 $s->{'host'}, "webmin", "tempname");
96 $s->{'host'}, "webmin",
97 "http_download", $mhost, $mport,
98 $mpage, $mtemp, \$err, undef, $mssl);
105 $irv = &remote_foreign_call(
106 $s->{'host'}, "webmin",
107 "install_webmin_module",
109 [ $base_remote_user ]);
111 push(@rv, [ 1, @$u ]);
119 print $wh &serialise_variable(\@rv);
127 # Get back all the results
129 foreach $h (@hosts) {
130 local $rh = "READ$p";
133 local $rv = &unserialise_variable($line);
135 local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
136 local $d = &server_name($s);
138 print &text('update_onhost', $d),"<br>\n";
140 print &text('update_failed', "Unknown reason"),"<p>\n";
143 print &text('update_failed', $rv),"<p>\n";
146 print &text('update_none', $rv),"<p>\n";
149 # Show list of modules
154 print &webmin::text($u->[0] ? 'update_mok' : 'update_mshow', "<b>$u->[1]</b>", "<b>$u->[2]</b>"),"<br>\n";
155 print " $webmin::text{'update_fixes'} : $u->[5]<br>\n";
166 print "<p><b>$text{'upgrade_done'}</b><p>\n";
169 &ui_print_footer("", $text{'index_return'});