Handle hostnames with upper-case letters
[webmin.git] / cluster-shell / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Shows a form for running a command, allowing the selection of a server or
4 # group of servers to run it on.
5
6 require './cluster-shell-lib.pl';
7 &ui_print_header(undef, $text{'index_title'}, "", "intro", 0, 1);
8
9 print "<form action=run.cgi method=post>\n";
10 print "<table>\n";
11
12 print "<tr> <td><b>$text{'index_cmd'}</b></td>\n";
13 print "<td><input name=cmd size=60></td> </tr>\n";
14
15 open(COMMANDS, $commands_file);
16 chop(@commands = <COMMANDS>);
17 close(COMMANDS);
18 if (@commands) {
19         print "<tr> <td align=right><b>$text{'index_old'}</b></td>\n";
20         print "<td><select name=old>\n";
21         foreach $c (&unique(@commands)) {
22                 print "<option>$c\n";
23                 }
24         print "</select> <input type=submit name=clear ",
25               "value='$text{'index_clear'}'></td> </tr>\n";
26         }
27
28 %serv = map { $_, 1 } split(/ /, $config{'server'});
29 print "<tr> <td valign=top><b>$text{'index_server'}</b></td>\n";
30 print "<td><select multiple size=5 name=server>\n";
31 printf "<option value=ALL %s>%s\n",
32         $serv{'ALL'} ? 'selected' : '', $text{'index_all'};
33 printf "<option value=* %s>%s\n",
34         $serv{'*'} ? 'selected' : '', $text{'index_this'};
35 foreach $s (grep { $_->{'user'} }
36                  sort { $a->{'host'} cmp $b->{'host'} }
37                       &servers::list_servers()) {
38         printf "<option value=%s %s>%s\n",
39                 $s->{'host'}, $serv{$s->{'host'}} ? "selected" : "",
40                 $s->{'host'}.($s->{'desc'} ? " (".$s->{'desc'}.")" : "");
41         }
42 foreach $g (&servers::list_all_groups()) {
43         $gn = "group_".$g->{'name'};
44         printf "<option value=%s %s>%s\n",
45                 $gn, $serv{$gn} ? "selected" : "",
46                 &text('index_group', $g->{'name'});
47         }
48 print "</select></td> </tr>\n";
49
50 print "<tr>\n";
51 print "<td colspan=2><input type=submit value='$text{'index_run'}'></td> </tr>\n";
52
53 print "</table></form>\n";
54
55 &ui_print_footer("/", $text{'index'});
56