Handle hostnames with upper-case letters
[webmin.git] / raid / save_mdadm.cgi
1 #!/usr/local/bin/perl
2 # Update mdadm.conf with notification settings
3
4 require './raid-lib.pl';
5 &ReadParse();
6 &error_setup($text{'notif_err'});
7
8 # Validate inputs
9 $notif = { };
10 if (!$in{'mailaddr_def'}) {
11         $in{'mailaddr'} =~ /^\S+\@\S+$/ || &error($text{'notif_emailaddr'});
12         $notif->{'MAILADDR'} = $in{'mailaddr'};
13         }
14 else {
15         $notif->{'MAILADDR'} = undef;
16         }
17 if (!$in{'mailfrom_def'}) {
18         $in{'mailfrom'} =~ /^\S+\@\S+$/ || &error($text{'notif_emailfrom'});
19         $notif->{'MAILFROM'} = $in{'mailfrom'};
20         }
21 else {
22         $notif->{'MAILFROM'} = undef;
23         }
24 if (!$in{'program_def'}) {
25         -x $in{'program'} || &error($text{'notif_eprogram'});
26         $notif->{'PROGRAM'} = $in{'program'};
27         }
28 else {
29         $notif->{'PROGRAM'} = undef;
30         }
31
32 # Save them
33 &lock_file($config{'mdadm'});
34 &save_mdadm_notifications($notif);
35 &unlock_file($config{'mdadm'});
36
37 # Enable/disable
38 if (&get_mdadm_action()) {
39         &save_mdadm_monitoring($in{'monitor'});
40         }
41
42 &webmin_log("notif");
43
44 &redirect("");
45