3 # Save configuration options
5 require './heartbeat-lib.pl';
7 @conf = &get_ha_config();
8 &error_setup($text{'conf_err'});
10 # Parse and validate inputs
11 for($i=0; defined($in{"serial_$i"}); $i++) {
12 push(@serials, $in{"serial_$i"}) if ($in{"serial_$i"});
14 &save_directive(\@conf, 'serial', \@serials );
16 if ($in{'baud_def'}) {
17 &save_directive(\@conf, 'baud', [ ]);
20 $in{'baud'} =~ /^\d+$/ || &error($text{'conf_ebaud'});
21 &save_directive(\@conf, 'baud', [ $in{'baud'} ]);
24 # changed (Christof Amelunxen, 22.08.2003)
26 if ($in{'bcasts_def'}) {
27 &save_directive(\@conf, 'bcast', [ ]);
30 @bcasts = split(/\s+/, $in{'bcasts'});
31 foreach $b (@bcasts) {
32 $b =~ /^\S+\d+$/ || &error(&text('conf_ebcastif', $b));
34 @bcasts || &error($text{'conf_ebcasts'});
35 &save_directive(\@conf, 'bcast', \@bcasts);
38 if ($in{'udpport_def'}) {
39 &save_directive(\@conf, 'udpport', [ ]);
42 $in{'udpport'} =~ /^\d+$/ || &error($text{'conf_eudpport'});
43 &save_directive(\@conf, 'udpport', [ $in{'udpport'} ]);
46 if ($in{'mcast_def'}) {
47 &save_directive(\@conf, 'mcast', [ ]);
50 $in{'mcast_dev'} =~ /^\S+\d+$/ || &error($text{'conf_emcast_dev'});
51 &check_ipaddress($in{'mcast_ip'}) || &error($text{'conf_emcast_ip'});
52 $in{'mcast_port'} =~ /^\d+$/ || &error($text{'conf_emcast_port'});
53 $in{'mcast_ttl'} =~ /^\d+$/ || &error($text{'conf_emcast_ttl'});
54 &save_directive(\@conf, 'mcast', [ join(" ",
55 $in{'mcast_dev'}, $in{'mcast_ip'}, $in{'mcast_port'},
56 $in{'mcast_ttl'}, $in{'mcast_loop'}) ] );
59 if ($in{'keepalive_def'}) {
60 &save_directive(\@conf, 'keepalive', [ ]);
63 $in{'keepalive'} =~ /^\d+$/ || &error($text{'conf_ekeepalive'});
64 &save_directive(\@conf, 'keepalive', [ $in{'keepalive'} ]);
67 if ($in{'deadtime_def'}) {
68 &save_directive(\@conf, 'deadtime', [ ]);
71 $in{'deadtime'} =~ /^\d+$/ || &error($text{'conf_edeadtime'});
72 &save_directive(\@conf, 'deadtime', [ $in{'deadtime'} ]);
75 if ($in{'watchdog_def'}) {
76 &save_directive(\@conf, 'watchdog', [ ]);
79 -r $in{'watchdog'} || &error($text{'conf_ewatchdog'});
80 &save_directive(\@conf, 'watchdog', [ $in{'watchdog'} ]);
83 @node = split(/\s+/, $in{'node'});
84 @node || &error($text{'conf_enonode'});
85 $uname = `uname -n 2>/dev/null`;
88 $found++ if ($n eq $uname);
90 !$uname || $found || &error(&text('conf_ethisnode', "<tt>$uname</tt>"));
91 &save_directive(\@conf, 'node', \@node);
93 if ($in{'logfile_def'}) {
94 &save_directive(\@conf, 'logfile', [ ]);
97 $in{'logfile'} =~ /^\S+$/ || &error($text{'conf_elogfile'});
98 &save_directive(\@conf, 'logfile', [ $in{'logfile'} ]);
101 if ($in{'logfacility_def'}) {
102 &save_directive(\@conf, 'logfacility', [ ]);
105 &save_directive(\@conf, 'logfacility', [ $in{'logfacility'} ]);
108 if ($in{'initdead_def'}) {
109 &save_directive(\@conf, 'initdead', [ ]);
112 $in{'initdead'} =~ /^\d+$/ || &error($text{'conf_einitdead'});
113 $in{'deadtime_def'} || $in{'initdead'} >= $in{'deadtime'}*2 ||
114 &error($text{'conf_einitdead2'});
115 &save_directive(\@conf, 'initdead', [ $in{'initdead'} ]);
118 # save nice failback behaviour
119 if (&version_atleast(1, 2, 0)) {
121 if ($in{'auto_failback'}) {
122 &save_directive(\@conf, 'auto_failback',
123 [ $in{'auto_failback'} ]);
126 &save_directive(\@conf, 'auto_failback', [ ]);
131 if ($in{'nice_failback_def'}) {
132 &save_directive(\@conf,'nice_failback',[ 'on' ]);
135 &save_directive(\@conf,'nice_failback', [ 'off' ]);