#!/usr/local/bin/perl
# index.cgi
# Display hosts on which software packages are being managed, a form for
# finding existing packages and a form for installing more
require './cluster-software-lib.pl';
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1);
# Display hosts on which software will be installed
print &ui_subheading($text{'index_hosts'});
@servers = &list_servers();
@hosts = &list_software_hosts();
if ($config{'sort_mode'} == 1) {
@hosts = sort { my ($as) = grep { $_->{'id'} == $a->{'id'} } @servers;
my ($bs) = grep { $_->{'id'} == $b->{'id'} } @servers;
lc($as->{'host'}) cmp lc($bs->{'host'}) } @hosts;
}
elsif ($config{'sort_mode'} == 2) {
@hosts = sort { my ($as) = grep { $_->{'id'} == $a->{'id'} } @servers;
my ($bs) = grep { $_->{'id'} == $b->{'id'} } @servers;
lc(&server_name($as)) cmp lc(&server_name($bs)) }@hosts;
}
$formno = 0;
foreach $h (@hosts) {
local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
next if (!$s);
local $count = @{$h->{'packages'}};
push(@titles, ($s->{'desc'} ? $s->{'desc'} :
$s->{'realhost'} ? "$s->{'realhost'}:$s->{'port'}" :
"$s->{'host'}:$s->{'port'}")."
".
&text('index_count', $count));
push(@links, "edit_host.cgi?id=$h->{'id'}");
push(@icons, "$gconfig{'webprefix'}/servers/images/$s->{'type'}.gif");
push(@installed, $count);
$gothost{$h->{'id'}}++;
}
if (@links) {
&icons_table(\@links, \@titles, \@icons);
}
else {
print "$text{'index_nohosts'}
\n"; } $formno++; # Show form for adding a server print "
| \n"; $formno += 2; print " | \n"; print "
\n";
$upid = time().$$;
print &ui_form_start("install_pack.cgi?id=$upid", "form-data", undef,
&read_parse_mime_javascript($upid, [ "upload" ])),"\n";
print &ui_oneradio("source", 0, $text{'index_local'}, 1),"\n",
&ui_textbox("local", undef, 50),"\n",
&file_chooser_button("local", 0, 2),"
\n";
print &ui_oneradio("source", 1, $text{'index_uploaded'}, 0),"\n",
&ui_upload("upload", 20),"
\n";
print &ui_oneradio("source", 2, $text{'index_ftp'}, 0),"\n",
&ui_textbox("url", undef, 50),"
",
" " x 5,&ui_checkbox("down", 1, $text{'index_down'}, 0),
"
\n";
# Show option for APT or YUM
if ($software::has_update_system) {
print &ui_oneradio("source", 3,
$software::text{$software::update_system.'_input'}, 0),
"\n",&ui_textbox("update", undef, 30),"\n",
&software::update_system_button("update",
$software::text{$software::update_system.'_find'});
print "
\n";
}
print &ui_submit($text{'index_installok'}),"\n";
print &ui_form_end();
}
&ui_print_footer("/", $text{'index'});