forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave_sched.cgi
executable file
·44 lines (37 loc) · 942 Bytes
/
save_sched.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/local/bin/perl
# save_sched.cgi
# Create, update or delete the rotation cron job
require './logrotate-lib.pl';
&ReadParse();
&foreign_require("cron", "cron-lib.pl");
@jobs = &cron::list_cron_jobs();
if ($in{'idx'} ne "") {
$oldjob = $job = $jobs[$in{'idx'}];
}
else {
$job = { 'user' => 'root',
'command' => &has_command($config{'logrotate'})." ".
$config{'logrotate_conf'},
'active' => 1 };
}
&lock_file(&cron::cron_file($job));
&error_setup($text{'sched_err'});
&cron::parse_times_input($job, \%in) if ($in{'sched'});
if ($oldjob && $in{'sched'}) {
# Just update
&cron::change_cron_job($job);
$action = "modify";
}
elsif ($oldjob && !$in{'sched'}) {
# Delete
&cron::delete_cron_job($job);
$action = "delete";
}
elsif (!$oldjob && $in{'sched'}) {
# Create new
&cron::create_cron_job($job);
$action = "create";
}
&unlock_file(&cron::cron_file($job));
&webmin_log($action, "sched");
&redirect("");