mirror of
https://github.com/webmin/webmin.git
synced 2025-08-16 14:51:18 +00:00
72 lines
1.9 KiB
Perl
Executable File
72 lines
1.9 KiB
Perl
Executable File
#!/usr/local/bin/perl
|
|
# refresh.cgi
|
|
# Reload the list of packages from all managed hosts
|
|
|
|
require './cluster-software-lib.pl';
|
|
&header($text{'refresh_title'}, "");
|
|
print "<hr>\n";
|
|
$| = 1;
|
|
|
|
print "<b>$text{'refresh_header'}</b><p>\n";
|
|
@hosts = &list_software_hosts();
|
|
@servers = &list_servers();
|
|
foreach $h (@hosts) {
|
|
local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
|
|
if ($s) {
|
|
# Refresh the list
|
|
&remote_foreign_require($s->{'host'}, "software",
|
|
"software-lib.pl");
|
|
local $gconfig = &remote_foreign_config($s->{'host'}, undef);
|
|
foreach $g ('os_type', 'os_version',
|
|
'real_os_type', 'real_os_version') {
|
|
$h->{$g} = $gconfig{$g};
|
|
}
|
|
local @old = map { $_->{'name'} } @{$h->{'packages'}};
|
|
undef($h->{'packages'});
|
|
local $n = &remote_foreign_call($s->{'host'}, "software",
|
|
"list_packages");
|
|
local $packages = &remote_eval($s->{'host'}, "software",
|
|
"\\%packages");
|
|
local @added;
|
|
for($i=0; $i<$n; $i++) {
|
|
push(@{$h->{'packages'}},
|
|
{ 'name' => $packages->{$i,'name'},
|
|
'class' => $packages->{$i,'class'},
|
|
'desc' => $packages->{$i,'desc'} });
|
|
$idx = &indexof($packages->{$i,'name'}, @old);
|
|
if ($idx < 0) {
|
|
push(@added, $packages->{$i,'name'});
|
|
}
|
|
else {
|
|
splice(@old, $idx, 1);
|
|
}
|
|
}
|
|
&save_software_host($h);
|
|
local $d = $s->{'desc'} ? $s->{'desc'} : $s->{'host'};
|
|
if (@added && @old) {
|
|
print &text('refresh_1', $d,
|
|
join(" ", @added),join(" ", @old)),"<br>\n";
|
|
}
|
|
elsif (@added) {
|
|
print &text('refresh_2', $d,
|
|
join(" ", @added)),"<br>\n";
|
|
}
|
|
elsif (@old) {
|
|
print &text('refresh_3', $d, join(" ", @old)),"<br>\n";
|
|
}
|
|
else {
|
|
print &text('refresh_4', $d,"<br>\n";
|
|
}
|
|
}
|
|
else {
|
|
# remove from managed list
|
|
#&delete_software_host($h);
|
|
print &text('refresh_del', $h->{'id'}),"<br>\n";
|
|
}
|
|
}
|
|
print "<p><b>$text{'refresh_done'}</b><p>\n";
|
|
|
|
print "<hr>\n";
|
|
&footer("", $text{'index_return'});
|
|
|