#!/usr/bin/perl # Ask if the user wants to delete multiple packages, and if so do it require './cluster-software-lib.pl'; &ReadParse(); &error_setup($text{'deletes_err'}); # Find the specified hosts @servers = &list_servers(); @hosts = &list_software_hosts(); if ($in{'server'} >= 0) { @hosts = grep { $_->{'id'} eq $in{'server'} } @hosts; } @got = map { &host_to_server($_) } @hosts; # Find the packages for each host @packs = split(/\0/, $in{'del'}); foreach $p (@packs) { foreach $h (@hosts) { ($pkg) = grep { $_->{'name'} eq $p } @{$h->{'packages'}}; if ($pkg) { push(@{$pkghosts{$h->{'id'}}}, $p); $pkgmap{$h->{'id'},$p} = 1; $found++; } } } $found || &error($text{'deletes_enone'}); &ui_print_header(undef, $text{'deletes_title'}, "", undef); if ($in{'sure'}) { # do the deletion print "",&text('deletes_desc', "".join(" ", @packs).""), "
\n";
&remote_multi_callback(\@got, $parallel_max, \&deletes_callback, undef,
\@rvs, \@errs, "software", "software-lib.pl");
# Show the results
$p = 0;
foreach $h (@hosts) {
$g = &host_to_server($h);
local $d = $g->{'desc'} ? $g->{'desc'} : $g->{'host'};
if ($errs[$p] || $rvs[$p]) {
print &text('delete_error', $d, $errs[$p] || $rvs[$p]),"
\n";
}
else {
print &text('delete_success', $d),"
\n";
local @newpacks = grep { !$pkgmap{$h->{'id'},$_->{'name'}} } @{$h->{'packages'}};
$h->{'packages'} = \@newpacks;
&save_software_host($h);
}
$p++;
}
print "
$text{'delete_done'}
\n"; &webmin_log("deletes", "package", undef, { 'packs' => \@packs }); } else { # Ask if the user is sure.. print "
\n"; print "