Handle hostnames with upper-case letters
[webmin.git] / cluster-software / edit_pack.cgi
1 #!/usr/local/bin/perl
2 # edit_pack.cgi
3 # Display details of a package
4
5 require './cluster-software-lib.pl';
6 &ReadParse();
7 &ui_print_header(undef, $text{'edit_title'}, "", "edit_pack");
8
9 # Find all hosts with the package
10 @hosts = &list_software_hosts();
11 @servers = &list_servers();
12 foreach $h (@hosts) {
13         foreach $p (@{$h->{'packages'}}) {
14                 if ($p->{'name'} eq $in{'package'}) {
15                         local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
16                         push(@got, $s);
17                         $version{$s} = $p->{'version'};
18                         $pkg = $p if (!$pkg);
19                         $checkon = $s if (!$s->{'id'});
20                         }
21                 }
22         }
23
24 # Get the details from this host, or the first in the list
25 $checkon = $got[0] if (!$checkon);
26 &remote_foreign_require($checkon->{'host'}, "software", "software-lib.pl");
27 @pinfo = &remote_foreign_call($checkon->{'host'}, "software", "package_info",
28                               $in{'package'});
29
30 # Show package details
31 print "<table border width=100%>\n";
32 print "<tr $tb> <td><b>",&text('edit_details', $checkon->{'desc'} ?
33         $checkon->{'desc'} : "<tt>$checkon->{'host'}</tt>"),"</b></td> </tr>\n";
34 print "<tr $cb> <td><table width=100%>\n";
35
36 # Description, if we have one
37 if ($pinfo[2]) {
38         print "<tr> <td valign=top width=20%><b>$text{'edit_desc'}</b></td>\n";
39         print "<td colspan=3><pre>",
40               &html_escape(&entities_to_ascii($pinfo[2])),
41               "</pre></td> </tr>\n";
42         }
43
44 print "<tr> <td width=20%><b>$text{'edit_pack'}</b></td> <td>$pinfo[0]</td>\n";
45 print "<td width=20%><b>$text{'edit_class'}</b></td> <td>",
46       $pinfo[1] ? $pinfo[1] : $text{'edit_none'},"</td> </tr>\n";
47
48 print "<tr> <td width=20%><b>$text{'edit_ver'}</b></td> <td>$pinfo[4]</td>\n";
49 print "<td width=20%><b>$text{'edit_vend'}</b></td> <td>$pinfo[5]</td> </tr>\n";
50
51 print "<tr> <td width=20%><b>$text{'edit_arch'}</b></td> <td>$pinfo[3]</td>\n";
52 print "<td width=20%><b>$text{'edit_inst'}</b></td> <td>$pinfo[6]</td> </tr>\n";
53 print "</table></td></tr></table><p>\n";
54
55 print "<table width=100%> <tr>\n";
56
57 # Show button to list files, if possible
58 if (!$pinfo[8]) {
59         print "<form action=list_pack.cgi>\n";
60         print "<input type=hidden name=package value=\"$pinfo[0]\">\n";
61         print "<input type=hidden name=search value=\"$in{'search'}\">\n";
62         print "<td align=left><input type=submit value=\"$text{'edit_list'}\">\n";
63         print "<select name=server>\n";
64         foreach $s (@got) {
65                 print "<option value='$s->{'id'}'>",
66                         $s->{'desc'} || $s->{'realhost'} || $s->{'host'};
67                 }
68         print "</select></td>\n";
69         print "</form>\n";
70         }
71
72 # Show button to un-install, if possible
73 if (!$pinfo[7]) {
74         print "<form action=delete_pack.cgi>\n";
75         print "<input type=hidden name=package value=\"$pinfo[0]\">\n";
76         print "<input type=hidden name=search value=\"$in{'search'}\">\n";
77         print "<td align=right>\n";
78         print "<input type=submit value=\"$text{'edit_uninst'}\">\n";
79         print "<select name=server>\n";
80         print "<option value=-1>$text{'edit_all'}\n";
81         foreach $s (@got) {
82                 print "<option value='$s->{'id'}'>",
83                         $s->{'desc'} || $s->{'realhost'} || $s->{'host'};
84                 }
85         print "</select></td>\n";
86         print "</form>\n";
87         }
88
89 print "</tr> </table><p>\n";
90
91 # Show hosts with the package
92 print &ui_hr();
93 print &ui_subheading($text{'edit_hosts'});
94 @icons = map { "/servers/images/$_->{'type'}.gif" } @got;
95 @links = map { "edit_host.cgi?id=$_->{'id'}" } @got;
96 @titles = map { ($_->{'desc'} ? $_->{'desc'} :
97                  $_->{'realhost'} ? "$_->{'realhost'}:$_->{'port'}" :
98                               "$_->{'host'}:$_->{'port'}").
99                 ($version{$_} ? "<br>$text{'edit_ver'} $version{$_}" : "") } @got;
100 &icons_table(\@links, \@titles, \@icons);
101
102 &remote_finished();
103 if ($in{'search'}) {
104         &ui_print_footer("search.cgi?search=$in{'search'}", $text{'search_return'});
105         }
106 else {
107         &ui_print_footer("", $text{'index_return'});
108         }
109
110