2 # Save, delete or create a scheduled copy
4 require './cluster-copy-lib.pl';
5 &error_setup($text{'save_err'});
9 $copy = &get_copy($in{'id'});
10 $job = &find_cron_job($copy);
15 &redirect("exec.cgi?id=$in{'id'}");
18 elsif ($in{'delete'}) {
22 &lock_file(&cron::cron_file($job));
23 &cron::delete_cron_job($job);
24 &unlock_file(&cron::cron_file($job));
28 # Check and parse inputs
29 $in{'files'} =~ s/\r//g;
30 @files = split(/\n/, $in{'files'});
32 $f =~ /^\// || &error(&text('save_efile', $f));
34 $copy->{'files'} = join("\t", @files);
35 @files || &error($text{'save_efiles'});
36 $in{'dest'} =~ /^\// || &error($text{'save_edest'});
37 if ($in{'email_def'}) {
38 $copy->{'email'} = '';
41 $in{'email'} =~ /^\S+$/ || &error($text{'save_eemail'});
42 $copy->{'email'} = $in{'email'};
44 $copy->{'dest'} = $in{'dest'};
45 $copy->{'dmode'} = $in{'dmode'};
46 $copy->{'before'} = $in{'before'};
47 $copy->{'cmd'} = $in{'cmd'};
48 $copy->{'beforelocal'} = !$in{'beforeremote'};
49 $copy->{'cmdlocal'} = !$in{'cmdremote'};
50 @servers = split(/\0/, $in{'servers'});
51 @servers || &error($text{'save_eservers'});
52 $copy->{'servers'} = join(" ", @servers);
53 $copy->{'sched'} = $in{'sched'};
54 &cron::parse_times_input($copy, \%in);
59 &lock_file(&cron::cron_file($job));
60 &cron::delete_cron_job($job);
63 &cron::create_wrapper($cron_cmd, $module_name, "copy.pl");
64 $job = { 'user' => 'root',
65 'command' => "$cron_cmd $copy->{'id'}",
67 'mins' => $copy->{'mins'},
68 'hours' => $copy->{'hours'},
69 'days' => $copy->{'days'},
70 'months' => $copy->{'months'},
71 'weekdays' => $copy->{'weekdays'},
72 'special' => $copy->{'special'} };
73 &lock_file(&cron::cron_file($job));
74 &cron::create_cron_job($job);
76 &unlock_file(&cron::cron_file($job)) if ($job);
78 &webmin_log($in{'new'} ? 'create' : $in{'delete'} ? 'delete' : 'modify',
79 'copy', undef, $copy);