Handle hostnames with upper-case letters
[webmin.git] / cluster-webmin / edit_config.cgi
1 #!/usr/local/bin/perl
2 # Display a form for editing this module's configuration on multiple hosts
3
4 require './cluster-webmin-lib.pl';
5 require '../config-lib.pl';
6 &ReadParse();
7
8 # Work out which hosts were selected
9 @hosts = &list_webmin_hosts();
10 @servers = &list_servers();
11 foreach $h (@hosts) {
12         local ($got) = grep { $_->{'dir'} eq $in{'mod'} } @{$h->{'modules'}};
13         if ($got) {
14                 push(@gothosts, $h);
15                 $gothosts{$h->{'id'}} = 1;
16                 }
17         }
18 @hosts = &create_on_parse(undef, \@gothosts, $in{'mod'}, 1);
19 @hosts = grep { $gothosts{$_->{'id'}} } @hosts;
20 @hosts || &error($text{'config_enone'});
21 %minfo = &get_module_info($in{'mod'});
22 %minfo || &error($text{'config_ethis'});
23
24 # Get the config on the first host, or the local host
25 ($getfrom) = grep { $_->{'id'} == 0 } @hosts;
26 $getfrom ||= $hosts[0];
27 ($serv) = grep { $_->{'id'} == $getfrom->{'id'} } @servers;
28 &remote_foreign_require($serv->{'host'}, "webmin", "webmin-lib.pl");
29 %fconfig = &remote_foreign_call($serv->{'host'}, "webmin", "foreign_config",
30                                 $in{'mod'});
31
32 # Show the config editor
33 %descmap = map { $_->{'id'}, $_->{'desc'} || $_->{'host'} } @servers;
34 $ondesc = $in{'server'} == -1 ? $text{'config_all'} :
35           $in{'server'} == -3 ? $text{'config_have'} :
36           $in{'server'} =~ /^group_(.*)/ ? &text('config_group', "$1") :
37                                    &text('config_on', $descmap{$in{'server'}});
38 &ui_print_header($ondesc, $text{'config_title'}, "");
39
40 print &ui_form_start("save_config.cgi", "post");
41 print &ui_hidden("mod", $in{'mod'});
42 foreach $h (@hosts) {
43         print &ui_hidden("_host", $h->{'id'});
44         }
45 print &ui_hidden("_getfrom", $getfrom->{'id'});
46 print &ui_table_start(&text('config_header', $minfo{'desc'}), "100%", 2);
47
48 $mdir = &module_root_directory($in{'mod'});
49 if (-r "$mdir/config_info.pl") {
50         # Module has a custom config editor
51         &foreign_require($in{'mod'}, "config_info.pl");
52         if (&foreign_defined($in{'mod'}, "config_form")) {
53                 $func++;
54                 &foreign_call($in{'mod'}, "config_form", \%fconfig);
55                 }
56         }
57 if (!$func) {
58         # Use config.info to create config inputs
59         &generate_config(\%fconfig, "$mdir/config.info", $in{'mod'});
60         }
61 print &ui_table_end();
62 print &ui_form_end([ [ "save", $text{'save'} ] ]);
63
64 &ui_print_footer("", $text{'index_return'});
65