3 # Save an existing cluster cron job, or create a new one
5 require './cluster-cron-lib.pl';
6 &error_setup($text{'save_err'});
9 @jobs = &list_cluster_jobs();
12 'cluster_id' => time()."-".$$ };
15 ($oldjob) = grep { $_->{'cluster_id'} eq $in{'id'} } @jobs;
16 $job->{'cluster_id'} = $oldjob->{'cluster_id'};
17 $job->{'type'} = $oldjob->{'type'};
18 $job->{'file'} = $oldjob->{'file'};
19 $job->{'line'} = $oldjob->{'line'};
20 $job->{'nolog'} = $oldjob->{'nolog'};
23 # Check and parse inputs
24 if ($in{"cmd"} !~ /\S/) {
25 &error($cron::text{'save_ecmd'});
28 &error($cron::text{'save_euser'});
30 &cron::parse_times_input($job, \%in);
31 $in{input} =~ s/\r//g; $in{input} =~ s/%/\\%/g;
32 $in{cmd} =~ s/%/\\%/g;
33 $job->{'active'} = $in{'active'};
34 $job->{'cluster_command'} = $in{'cmd'};
35 if ($in{input} =~ /\S/) {
36 @inlines = split(/\n/ , $in{input});
37 $job->{'cluster_input'} .= join('%' , @inlines);
39 $job->{'command'} = "$cluster_cron_cmd $job->{'cluster_id'}";
40 $job->{'cluster_user'} = $in{'user'};
41 $job->{'user'} = 'root';
42 $job->{'cluster_server'} = join(" ", split(/\0/, $in{'server'}));
44 # Make sure the wrapper script exists
45 if (!-r $cluster_cron_cmd) {
46 &lock_file($cluster_cron_cmd);
47 &cron::create_wrapper($cluster_cron_cmd, $module_name, "cron.pl");
48 &unlock_file($cluster_cron_cmd);
52 # Editing an existing job
53 &modify_cluster_job($job);
57 &create_cluster_job($job);
61 &webmin_log("create", "cron", $job->{'cluster_user'}, $job);
64 &webmin_log("modify", "cron", $job->{'cluster_user'}, $job);