2 # Add or update a server or group from the webmin servers module
4 require './ipfw-lib.pl';
6 &foreign_require("servers", "servers-lib.pl");
7 @allservers = grep { $_->{'user'} } &servers::list_servers();
11 @add = grep { $_->{'id'} eq $in{'server'} } @allservers;
12 &error_setup($text{'add_err'});
13 $msg = &text('add_msg', &server_name($add[0]));
16 # Add all from a group
17 ($group) = grep { $_->{'name'} eq $in{'group'} }
18 &servers::list_all_groups(\@allservers);
19 foreach $m (@{$group->{'members'}}) {
20 push(@add, grep { $_->{'host'} eq $m } @allservers);
22 &error_setup($text{'add_gerr'});
23 $msg = &text('add_gmsg', $in{'group'});
26 &ui_print_header(undef, $text{'add_title'}, "");
27 print "<b>$msg</b><p>\n";
29 # Setup error handler for down hosts
32 $add_error_msg = join("", @_);
34 &remote_error_setup(\&add_error);
36 # Make sure each host is set up for firewalling
38 $add_error_msg = undef;
39 local $firewall = &remote_foreign_check($s, "ipfw");
41 print "$add_error_msg<p>\n";
45 print &text('add_echeck', $s),"<p>\n";
48 &remote_foreign_require($s, "ipfw", "ipfw-lib.pl");
50 local $ok = &remote_foreign_call($s, "ipfw",
51 "foreign_installed", "ipfw");
53 print &text('add_eok'),"<p>\n";
57 $iconfig = &remote_foreign_config($s, "ipfw");
58 $live = &remote_foreign_call($s, "ipfw",
59 "get_config", "$iconfig->{'ipfw'} show |");
60 print &text('add_ok', $s->{'host'}, scalar(@$live)),"<p>\n";
61 &add_cluster_server($s);
65 &webmin_log("add", "host", $add[0]->{'host'});
68 &webmin_log("add", "group", $in{'group'});
71 &ui_print_footer("cluster.cgi", $text{'cluster_return'});