2 # Create, update or delete a special client used as a group
4 require './bacula-backup-lib.pl';
7 $conf = &get_director_config();
8 $parent = &get_director_config_parent();
9 @clients = &find("Client", $conf);
12 @nodegroups = &list_node_groups();
13 $ngname = $in{'old'} || $in{'new'};
14 ($nodegroup) = grep { $_->{'name'} eq $ngname } @nodegroups;
17 $client = &find_by("Name", "ocgroup_".$in{'old'}, \@clients);
18 $client || &error($text{'group_egone'});
21 $client = { 'type' => 1,
26 &lock_file($parent->{'file'});
28 # Just delete this one
30 #$name = &find_value("Name", $client->{'members'});
31 #$child = &find_dependency("Client", $name, [ "Job", "JobDefs" ], $conf);
32 #$child && &error(&text('client_echild', $child));
33 &save_directive($conf, $parent, $client, undef, 0);
36 # Validate and store inputs
37 &error_setup($text{'group_err'});
39 &save_directive($conf, $client, "Name", "ocgroup_".$in{'new'}, 1);
40 $clash = &find_by("Name", "ocgroup_".$in{'name'}, \@clients);
41 $clash && &error($text{'group_eclash'});
44 &save_directive($conf, $client, "Address", "localhost", 1);
46 $in{'pass'} || &error($text{'client_epass'});
47 &save_directive($conf, $client, "Password", $in{'pass'}, 1);
49 $in{'port'} =~ /^\d+$/ && $in{'port'} > 0 && $in{'port'} < 65536 ||
50 &error($text{'client_eport'});
51 &save_directive($conf, $client, "FDPort", $in{'port'}, 1);
53 &save_directive($conf, $client, "Catalog", $in{'catalog'}, 1);
55 &save_directive($conf, $client, "AutoPrune", $in{'prune'} || undef, 1);
57 $fileret = &parse_period_input("fileret");
58 $fileret || &error($text{'client_efileret'});
59 &save_directive($conf, $client, "File Retention", $fileret, 1);
61 $jobret = &parse_period_input("jobret");
62 $jobret || &error($text{'client_ejobret'});
63 &save_directive($conf, $client, "Job Retention", $jobret, 1);
67 &save_directive($conf, $parent, undef, $client, 0);
72 # Force update to all dependent clients
73 &sync_group_clients($nodegroup);
77 &unlock_file($parent->{'file'});
78 &auto_apply_configuration();
79 &webmin_log($in{'new'} ? "create" : $in{'delete'} ? "delete" : "modify",
81 &redirect("list_groups.cgi");