forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_sched.cgi
More file actions
executable file
·53 lines (46 loc) · 1.12 KB
/
save_sched.cgi
File metadata and controls
executable file
·53 lines (46 loc) · 1.12 KB
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
44
45
46
47
48
49
50
51
52
#!/usr/local/bin/perl
# Update scheduled checking
require './cluster-shutdown-lib.pl';
&ReadParse();
&error_setup($text{'sched_err'});
# Validate and store inputs
$job = &find_cron_job();
if ($in{'sched'}) {
$in{'email'} =~ /\S/ || &error($text{'sched_eemail'});
$config{'email'} = $in{'email'};
if ($in{'smtp_def'}) {
delete($config{'smtp'});
}
else {
&to_ipaddress($in{'smtp'}) || &to_ip6address($in{'smtp'}) ||
&error($text{'sched_esmtp'});
$config{'smtp'} = $in{'smtp'};
}
&save_module_config();
}
# Create or delete cron job
&cron::create_wrapper($cron_cmd, $module_name, "check.pl");
if ($in{'sched'} && !$job) {
$job = { 'command' => $cron_cmd,
'user' => 'root',
'active' => 1,
'mins' => '*/5',
'hours' => '*',
'days' => '*',
'months' => '*',
'weekdays' => '*',
};
&cron::create_cron_job($job);
}
elsif (!$in{'sched'} && $job) {
&cron::delete_cron_job($job);
}
# Tell the user
&ui_print_header(undef, $text{'sched_title'}, "");
if ($in{'sched'}) {
print $text{'sched_enabled'},"<p>\n";
}
else {
print $text{'sched_disabled'},"<p>\n";
}
&ui_print_footer("", $text{'index_return'});