Handle hostnames with upper-case letters
[webmin.git] / cluster-webmin / save_config.cgi
1 #!/usr/local/bin/perl
2 # Update the configuration for a module on multiple hosts
3
4 require './cluster-webmin-lib.pl';
5 require '../config-lib.pl';
6 &ReadParse();
7 &error_setup($text{'config_err'});
8
9 # Get the current config
10 @hosts = &list_webmin_hosts();
11 @servers = &list_servers();
12 ($getfrom) = grep { $_->{'id'} == $in{'_getfrom'} } @hosts;
13 ($serv) = grep { $_->{'id'} == $getfrom->{'id'} } @servers;
14 &remote_foreign_require($serv->{'host'}, "webmin", "webmin-lib.pl");
15 %fconfig = &remote_foreign_call($serv->{'host'}, "webmin", "foreign_config",
16                                 $in{'mod'});
17
18 # Call the config parser
19 $mdir = &module_root_directory($in{'mod'});
20 if (-r "$mdir/config_info.pl") {
21         # Module has a custom config editor
22         &foreign_require($in{'mod'}, "config_info.pl");
23         if (&foreign_defined($in{'mod'}, "config_save")) {
24                 $func++;
25                 &foreign_call($in{'mod'}, "config_save", \%fconfig);
26                 }
27         }
28 if (!$func) {
29         # Use config.info to parse config inputs
30         &parse_config(\%fconfig, "$mdir/config.info", $in{'mod'});
31         }
32
33 # Write out to all hosts
34 foreach $hid (split(/\0/, $in{'_host'})) {
35         ($serv) = grep { $_->{'id'} == $hid } @servers;
36         if ($hid != $getfrom->{'id'}) {
37                 &remote_foreign_require($serv->{'host'}, "webmin", "webmin-lib.pl");
38                 }
39         &remote_foreign_call($serv->{'host'}, "webmin", "save_module_config",
40                              \%fconfig, $in{'mod'});
41         }
42 &redirect("edit_mod.cgi?mod=$in{'mod'}");
43