2 # Add or update a server or group from the webmin servers module
4 require './lpadmin-lib.pl';
5 $access{'cluster'} || &error($text{'cluster_ecannot'});
7 &foreign_require("servers", "servers-lib.pl");
8 @allservers = grep { $_->{'user'} } &servers::list_servers();
12 @add = grep { $_->{'id'} eq $in{'server'} } @allservers;
13 &error_setup($text{'add_err'});
14 $msg = &text('add_msg', &server_name($add[0]));
17 # Add all from a group
18 ($group) = grep { $_->{'name'} eq $in{'group'} }
19 &servers::list_all_groups(\@allservers);
20 foreach $m (@{$group->{'members'}}) {
21 push(@add, grep { $_->{'host'} eq $m } @allservers);
23 &error_setup($text{'add_gerr'});
24 $msg = &text('add_gmsg', $in{'group'});
27 &ui_print_header(undef, $text{'add_title'}, "");
28 print "<b>$msg</b><p>\n";
30 # Setup error handler for down hosts
33 $add_error_msg = join("", @_);
35 &remote_error_setup(\&add_error);
37 # Make sure each host is set up for printer administration
39 $add_error_msg = undef;
40 local $host = { 'id' => $s->{'id'} };
41 local $lpadmin = &remote_foreign_check($s->{'host'}, "lpadmin");
43 print "$add_error_msg<p>\n";
47 print &text('add_echeck', $s->{'host'}),"<p>\n";
50 &remote_foreign_require($s->{'host'}, "lpadmin", "lpadmin-lib.pl");
51 local $lconfig = &remote_foreign_config($s, "lpadmin");
52 if ($lconfig->{'print_style'} ne $config{'print_style'}) {
53 print &text('add_ediff', $s->{'host'},
54 $text{'style_'.$lconfig->{'print_style'}}),"<p>\n";
57 if ($lconfig->{'driver_style'} ne $config{'driver_style'}) {
58 print &text('add_ediff', $s->{'host'},
59 $lconfig->{'driver_style'} || "Webmin"),"<p>\n";
63 @printers = &remote_foreign_call($s->{'host'}, "lpadmin",
65 print &text('add_ok', $s->{'host'}, scalar(@printers)),"<p>\n";
66 &add_cluster_server($s);
70 &webmin_log("add", "host", $add[0]->{'host'});
73 &webmin_log("add", "group", $in{'group'});
76 &ui_print_footer("cluster.cgi", $text{'cluster_return'});