X7ROOT File Manager
Current Path:
/usr/libexec/webmin/cluster-software
usr
/
libexec
/
webmin
/
cluster-software
/
📁
..
📄
CHANGELOG
(1.01 KB)
📄
add.cgi
(904 B)
📄
close.cgi
(272 B)
📄
closeall.cgi
(179 B)
📄
cluster-software-lib.pl
(9.51 KB)
📄
compare.cgi
(1.81 KB)
📄
compare_form.cgi
(1.13 KB)
📄
config
(25 B)
📄
config.info
(108 B)
📄
config.info.ca
(133 B)
📄
config.info.cs
(82 B)
📄
config.info.de
(125 B)
📄
config.info.es
(90 B)
📄
config.info.fr
(134 B)
📄
config.info.hr
(0 B)
📄
config.info.ms
(131 B)
📄
config.info.nl
(130 B)
📄
config.info.no
(129 B)
📄
config.info.pl
(121 B)
📄
defaultacl
(6 B)
📄
delete_host.cgi
(254 B)
📄
delete_pack.cgi
(3.15 KB)
📄
delete_packs.cgi
(2.86 KB)
📄
do_install.cgi
(7.11 KB)
📄
do_install_serial.cgi
(3.55 KB)
📄
edit_host.cgi
(3.84 KB)
📄
edit_pack.cgi
(3.33 KB)
📁
help
📁
images
📄
index.cgi
(4.87 KB)
📄
install_pack.cgi
(4.82 KB)
📁
lang
📄
list_pack.cgi
(2.28 KB)
📄
module.info
(427 B)
📄
module.info.af
(0 B)
📄
module.info.af.auto
(154 B)
📄
module.info.ar
(0 B)
📄
module.info.ar.auto
(201 B)
📄
module.info.be
(0 B)
📄
module.info.be.auto
(282 B)
📄
module.info.bg
(0 B)
📄
module.info.bg.auto
(251 B)
📄
module.info.ca
(155 B)
📄
module.info.ca.auto
(31 B)
📄
module.info.cs
(40 B)
📄
module.info.cs.auto
(122 B)
📄
module.info.da
(0 B)
📄
module.info.da.auto
(153 B)
📄
module.info.de
(133 B)
📄
module.info.de.auto
(25 B)
📄
module.info.el
(0 B)
📄
module.info.el.auto
(263 B)
📄
module.info.es
(39 B)
📄
module.info.es.auto
(119 B)
📄
module.info.eu
(0 B)
📄
module.info.eu.auto
(141 B)
📄
module.info.fa
(0 B)
📄
module.info.fa.auto
(228 B)
📄
module.info.fi
(0 B)
📄
module.info.fi.auto
(156 B)
📄
module.info.fr
(41 B)
📄
module.info.fr.auto
(139 B)
📄
module.info.he
(0 B)
📄
module.info.he.auto
(186 B)
📄
module.info.hr
(0 B)
📄
module.info.hr.auto
(155 B)
📄
module.info.hu
(33 B)
📄
module.info.hu.auto
(125 B)
📄
module.info.it
(0 B)
📄
module.info.it.auto
(147 B)
📄
module.info.ja
(0 B)
📄
module.info.ja.auto
(228 B)
📄
module.info.ko
(0 B)
📄
module.info.ko.auto
(193 B)
📄
module.info.lt
(0 B)
📄
module.info.lt.auto
(181 B)
📄
module.info.lv
(0 B)
📄
module.info.lv.auto
(165 B)
📄
module.info.ms
(119 B)
📄
module.info.ms.auto
(25 B)
📄
module.info.mt
(0 B)
📄
module.info.mt.auto
(158 B)
📄
module.info.nl
(35 B)
📄
module.info.nl.auto
(122 B)
📄
module.info.no
(35 B)
📄
module.info.no.auto
(115 B)
📄
module.info.pl
(132 B)
📄
module.info.pl.auto
(33 B)
📄
module.info.pt
(0 B)
📄
module.info.pt.auto
(154 B)
📄
module.info.pt_BR
(0 B)
📄
module.info.pt_BR.auto
(163 B)
📄
module.info.ro
(0 B)
📄
module.info.ro.auto
(152 B)
📄
module.info.ru
(0 B)
📄
module.info.ru.auto
(278 B)
📄
module.info.sk
(0 B)
📄
module.info.sk.auto
(162 B)
📄
module.info.sl
(0 B)
📄
module.info.sl.auto
(159 B)
📄
module.info.sv
(0 B)
📄
module.info.sv.auto
(151 B)
📄
module.info.th
(0 B)
📄
module.info.th.auto
(351 B)
📄
module.info.tr
(0 B)
📄
module.info.tr.auto
(159 B)
📄
module.info.uk
(0 B)
📄
module.info.uk.auto
(272 B)
📄
module.info.ur
(0 B)
📄
module.info.ur.auto
(235 B)
📄
module.info.vi
(0 B)
📄
module.info.vi.auto
(162 B)
📄
module.info.zh
(0 B)
📄
module.info.zh.auto
(131 B)
📄
module.info.zh_TW
(0 B)
📄
module.info.zh_TW.auto
(140 B)
📄
open.cgi
(250 B)
📄
openall.cgi
(427 B)
📄
prefs.info
(28 B)
📄
refresh.cgi
(1.61 KB)
📄
search.cgi
(1.92 KB)
Editing: cluster-software-lib.pl
# cluster-software-lib.pl # common functions for installing packages across a cluster # XXX refresh all packages after installing BEGIN { push(@INC, ".."); }; use WebminCore; &init_config(); &foreign_require("servers", "servers-lib.pl"); &foreign_require("software", "software-lib.pl"); $parallel_max = 20; %access = &get_module_acl(); # list_software_hosts() # Returns a list of all hosts whose software is being managed by this module sub list_software_hosts { local @rv; local %smap = map { $_->{'id'}, $_ } &list_servers(); local $hdir = "$module_config_directory/hosts"; opendir(DIR, $hdir); foreach $h (readdir(DIR)) { next if ($h =~ /\.host$/ || $h eq '.' || $h eq '..'); local %host = ( 'id', $h ); next if (!$smap{$h}); # underlying server was deleted opendir(PDIR, "$hdir/$h") || next; foreach $p (readdir(PDIR)) { next if ($p eq "." || $p eq ".."); local %pkg; &read_file("$hdir/$h/$p", \%pkg); push(@{$host{'packages'}}, \%pkg); } closedir(PDIR); &read_file("$hdir/$h.host", \%host); push(@rv, \%host); } closedir(DIR); return @rv; } # save_software_host(&host) # Add or update a managed host with it's package list sub save_software_host { local $hdir = "$module_config_directory/hosts"; mkdir($hdir, 0700); if (-d "$hdir/$_[0]->{'id'}") { opendir(DIR, "$hdir/$_[0]->{'id'}"); foreach $f (readdir(DIR)) { unlink("$hdir/$_[0]->{'id'}/$f"); } closedir(DIR); } else { mkdir("$hdir/$_[0]->{'id'}", 0700); } foreach $p (@{$_[0]->{'packages'}}) { local $pname = $p->{'name'}; $pname =~ s/\//_/g; &write_file("$hdir/$_[0]->{'id'}/$pname", $p); } local %h = %{$_[0]}; delete($h{'packages'}); &write_file("$hdir/$_[0]->{'id'}.host", \%h); } # delete_software_host(&host) sub delete_software_host { &unlink_file("$module_config_directory/hosts/$_[0]->{'id'}.host"); &unlink_file("$module_config_directory/hosts/$_[0]->{'id'}"); } # list_servers() # Returns a list of all servers from the webmin servers module that can be # managed, plus this server sub list_servers { local @servers = &servers::list_servers_sorted(); return ( &servers::this_server(), grep { $_->{'user'} } @servers ); } # host_to_server(&host|id) sub host_to_server { local $id = ref($_[0]) ? $_[0]->{'id'} : $_[0]; local ($serv) = grep { $_->{'id'} eq $id } &list_servers(); return $serv; } # server_name(&server) sub server_name { return $_[0]->{'desc'} || $_[0]->{'realhost'} || $_[0]->{'host'}; } # get_heiropen(hostid) # Returns an array of open categories sub get_heiropen { open(HEIROPEN, "<$module_config_directory/heiropen.$_[0]"); local @heiropen = <HEIROPEN>; chop(@heiropen); close(HEIROPEN); return @heiropen; } # save_heiropen(&heir, hostid) sub save_heiropen { &open_tempfile(HEIR, ">$module_config_directory/heiropen.$_[1]"); foreach $h (@{$_[0]}) { &print_tempfile(HEIR, $h,"\n"); } &close_tempfile(HEIR); } # create_on_input(desc, [no-donthave], [no-have]) sub create_on_input { local @hosts = &list_software_hosts(); local @servers = &list_servers(); local @opts; push(@opts, [ -1, $text{'edit_all'} ]); push(@opts, [ -2, $text{'edit_donthave'} ]) if (!$_[1]); push(@opts, [ -3, $text{'edit_have'} ]) if (!$_[2]); local @groups = &servers::list_all_groups(\@servers); local $h; foreach $h (@hosts) { local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers; if ($s) { push(@opts, [ $s->{'id'}, $s->{'desc'} || $s->{'realhost'} || $s->{'host'} ]); $gothost{$s->{'host'}}++; } } local $g; foreach $g (@groups) { local ($found, $m); foreach $m (@{$g->{'members'}}) { ($found++, last) if ($gothost{$m}); } push(@opts, [ "group_$g->{'name'}", &text('edit_group', $g->{'name'}) ]) if ($found); } local $sel = &ui_select("server", undef, \@opts); if ($_[0]) { print &ui_table_row($_[0], $sel); } else { print $sel; } } # create_on_parse(prefix, &already, name) sub create_on_parse { local @hosts = &list_software_hosts(); local @servers = &list_servers(); if ($in{'server'} == -2) { # Install on hosts that don't have it local %already = map { $_->{'id'}, 1 } @{$_[1]}; @hosts = grep { !$already{$_->{'id'}} } @hosts; print "<b>",&text($_[0].'3', $_[2]),"</b><p>\n"; } elsif ($in{'server'} == -3) { # Install on hosts that do have it local %already = map { $_->{'id'}, 1 } @{$_[1]}; @hosts = grep { $already{$_->{'id'}} } @hosts; print "<b>",&text($_[0].'6', $_[2]),"</b><p>\n"; } elsif ($in{'server'} =~ /^group_(.*)/) { # Install on members of some group local ($group) = grep { $_->{'name'} eq $1 } &servers::list_all_groups(\@servers); @hosts = grep { local $hid = $_->{'id'}; local ($s) = grep { $_->{'id'} == $hid } @servers; &indexof($s->{'host'}, @{$group->{'members'}}) >= 0 } @hosts; print "<b>",&text($_[0].'4', $_[2], $group->{'name'}), "</b><p>\n"; } elsif ($in{'server'} != -1) { # Just install on one host @hosts = grep { $_->{'id'} == $in{'server'} } @hosts; local ($s) = grep { $_->{'id'} == $hosts[0]->{'id'} } @servers; print "<b>",&text($_[0].'5', $_[2], &server_name($s)),"</b><p>\n"; } else { # Installing on every host print "<b>",&text($_[0], join(" ", @names)),"</b><p>\n"; } return @hosts; } # Setup error handler for down hosts sub add_error { $add_error_msg = join("", @_); } # add_managed_host(&server) # Adds a new system to this module for management, and returns a status code # (0 or 1) and error or information message sub add_managed_host { local ($s) = @_; &remote_error_setup(\&add_error); # Get the packages for each host local %sconfig = &foreign_config("software"); $add_error_msg = undef; local $host = { 'id' => $s->{'id'} }; local $soft = &remote_foreign_check($s->{'host'}, "software"); if ($add_error_msg) { return (0, $add_error_msg); } if (!$soft) { return (0, &text('add_echeck', $s->{'host'})); } &remote_foreign_require($s->{'host'}, "software", "software-lib.pl"); local $rconfig = &remote_foreign_config($s->{'host'}, "software"); #if ($rconfig->{'package_system'} ne $sconfig{'package_system'}) { # return (0, &text('add_esystem', $s->{'host'})); # } $host->{'package_system'} = $rconfig->{'package_system'}; local $gconfig = &remote_foreign_config($s->{'host'}, undef); foreach $g ('os_type', 'os_version', 'real_os_type', 'real_os_version') { $host->{$g} = $gconfig->{$g}; } local $n = &remote_foreign_call($s->{'host'}, "software", "list_packages"); local $packages = &remote_eval($s->{'host'}, "software", "\\%packages"); for(my $i=0; $i<$n; $i++) { push(@{$host->{'packages'}}, { 'name' => $packages->{$i,'name'}, 'class' => $packages->{$i,'class'}, 'desc' => $packages->{$i,'desc'}, 'version' => $packages->{$i,'version'}, 'nouninstall' => $packages->{$i,'nouninstall'}, 'nolist' => $packages->{$i,'nolist'}, }); } &save_software_host($host); return (1, &text('add_ok', &server_name($s), $n)); } # refresh_packages(&hosts) # Update the local cache with actual installed packages. Returns an array # of either an error messages or two arrays of added and removed packages. sub refresh_packages { local ($hosts) = @_; local @servers = &list_servers(); # Setup error handler for down hosts sub ref_error { $ref_error_msg = join("", @_); } &remote_error_setup(\&ref_error); local $p = 0; foreach my $h (@$hosts) { local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers; local ($rh = "READ$p", $wh = "WRITE$p"); pipe($rh, $wh); if (!fork()) { close($rh); if ($s) { # Refresh the list &remote_foreign_require($s->{'host'}, "software", "software-lib.pl"); if ($ref_error_msg) { # Host is down .. print $wh &serialise_variable($ref_error_msg); exit; } 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++) { next if (!$packages->{$i,'name'}); push(@{$h->{'packages'}}, { 'name' => $packages->{$i,'name'}, 'class' => $packages->{$i,'class'}, 'desc' => $packages->{$i,'desc'}, 'version' => $packages->{$i,'version'}, 'nouninstall' => $packages->{$i,'nouninstall'}, 'nolist' => $packages->{$i,'nolist'}, }); $idx = &indexof($packages->{$i,'name'}, @old); if ($idx < 0) { push(@added, $packages->{$i,'name'}); } else { splice(@old, $idx, 1); } } &save_software_host($h); $rv = [ \@added, \@old ]; } else { # remove from managed list &delete_software_host($h); $rv = undef; } print $wh &serialise_variable($rv); close($wh); exit; } close($wh); $p++; } # Read back results $p = 0; local @results; foreach my $h (@hosts) { local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers; local $rh = "READ$p"; local $line = <$rh>; local $rv = &unserialise_variable($line); close($rh); push(@results, $rv); $p++; } return @results; } # same_package_system(&host) # Returns 1 if some host is using the same package system as this master sub same_package_system { local ($host) = @_; return !$host->{'package_system'} || $host->{'package_system'} eq $software::config{'package_system'}; } 1;
Upload File
Create Folder