3 # Save scheduled monitoring options
5 require './status-lib.pl';
6 $access{'sched'} || &error($text{'sched_ecannot'});
8 &error_setup($text{'sched_err'});
10 # Parse and save inputs
11 $in{'email_def'} || $in{'email'} =~ /\S/ || &error($text{'sched_eemail'});
12 $config{'sched_email'} = $in{'email_def'} ? '' : $in{'email'};
13 if ($config{'pager_cmd'}) {
14 $config{'sched_pager'} = $in{'pager_def'} ? '' : $in{'pager'};
17 delete($config{'sched_carrier'});
18 delete($config{'sched_sms'});
21 $config{'sched_carrier'} = $in{'carrier'};
22 ($carrier) = grep { $_->{'id'} eq $in{'carrier'} }
24 if ($carrier->{'alpha'}) {
25 $in{'sms'} =~ /^\S+$/ || &error($text{'sched_esmsname'});
28 $in{'sms'} =~ /^\d+$/ || &error($text{'sched_esmsnumber'});
30 $config{'sched_sms'} = $in{'sms'};
32 if ($in{'from_def'}) {
33 delete($config{'sched_from'});
36 $in{'from'} =~ /^\S+$/ || &error($text{'sched_efrom'});
37 $config{'sched_from'} = $in{'from'};
39 if ($in{'smtp_def'}) {
40 if (!$in{'from_def'}) {
41 &foreign_require("mailboxes");
42 $err = &mailboxes::test_mail_system();
43 $err && &error(&text('sched_eemailserver', $err));
45 delete($config{'sched_smtp'});
48 if (!$in{'from_def'}) {
49 &to_ipaddress($in{'smtp'}) || &to_ip6address($in{'smtp'}) ||
50 &error($text{'sched_esmtp'});
52 $config{'sched_smtp'} = $in{'smtp'};
54 $config{'sched_mode'} = $in{'mode'};
55 $in{'int'} =~ /^\d+$/ || &error($text{'sched_eint'});
56 $config{'sched_int'} = $in{'int'};
57 $config{'sched_period'} = $in{'period'};
58 $in{'offset'} =~ /^\d+$/ || &error($text{'sched_eoffset'});
59 $config{'sched_offset'} = $in{'offset'};
60 $config{'sched_warn'} = $in{'warn'};
61 $config{'sched_single'} = $in{'single'};
62 @hours = split(/\0/, $in{'hours'});
63 @hours || &error($text{'sched_ehours'});
64 $config{'sched_hours'} = @hours == 24 ? '' : join(" ", @hours);
65 @days = split(/\0/, $in{'days'});
66 @days || &error($text{'sched_edays'});
67 $config{'sched_days'} = @days == 7 ? '' : join(" ", @days);
68 &lock_file("$module_config_directory/config");
69 &save_module_config();
70 &unlock_file("$module_config_directory/config");
72 # Setup or remove the cron job