Handle hostnames with upper-case letters
[webmin.git] / heartbeat / edit_conf.cgi
1 #!/usr/local/bin/perl
2 # edit_conf.cgi
3 # Display ha_conf options
4
5 require './heartbeat-lib.pl';
6 &ui_print_header(undef, $text{'conf_title'}, "");
7
8 @conf = &get_ha_config();
9 print "<form action=save_conf.cgi>\n";
10 print "<table border width=100%>\n";
11 print "<tr $tb> <td><b>$text{'conf_header'}</b></td> </tr>\n";
12 print "<tr $cb> <td><table width=100%>\n";
13
14 @serials = &find("serial", \@conf);
15 print "<tr> <td><b>$text{'conf_serials'}</b></td>\n";
16 print "<td>\n";
17 for($i=0; $i<=@serials; $i++) {
18         local $sfound;
19         print "<select name=serial_$i>\n";
20         opendir(DIR, "/dev");
21         printf "<option value='' %s>%s\n",
22                 $serials[$i] ? "" : "selected",
23                 $i ? "&nbsp;" : $text{'conf_none'};
24         foreach $p (glob($config{'serials'})) {
25                 printf "<option %s>%s\n",
26                         $p eq $serials[$i] ? "selected" : "", $p;
27                 $sfound++ if ($p eq $serials[$i]);
28                 }
29         closedir(DIR);
30         print "<option selected>$serials[$i]\n" if ($serials[$i] && !$sfound);
31         print "</select>\n";
32         }
33 print "</td> </tr>\n";
34
35 $baud = &find("baud", \@conf);
36 print "<tr><td><b>$text{'conf_baud'}</b></td> <td>\n";
37 printf "<input type=radio name=baud_def value=1 %s> %s\n",
38         $baud ? "" : "checked", $text{'default'};
39 printf "<input type=radio name=baud_def value=0 %s>\n",
40         $baud ? "checked" : "";
41 printf "<input name=baud size=6 value='%s'></td> </tr>\n", $baud;
42
43 # changed (Christof Amelunxen, 22.08.2003)
44 # udp directive replaced by bcast
45 @bcasts = &find("bcast", \@conf);
46 print "<tr> <td><b>$text{'conf_bcasts'}</b></td> <td>\n";
47 printf "<input type=radio name=bcasts_def value=1 %s> %s\n",
48         @bcasts ? "" : "checked", $text{'conf_none'};
49 printf "<input type=radio name=bcasts_def value=0 %s>\n",
50         @bcasts ? "checked" : "";
51 printf "<input name=bcasts size=20 value='%s'></td>\n",
52         join(" ", @bcasts);
53
54 $udpport = &find("udpport", \@conf);
55 print "<tr><td><b>$text{'conf_udpport'}</b></td> <td>\n";
56 printf "<input type=radio name=udpport_def value=1 %s> %s\n",
57         $udpport ? "" : "checked", $text{'default'};
58 printf "<input type=radio name=udpport_def value=0 %s>\n",
59         $udpport ? "checked" : "";
60 printf "<input name=udpport size=5 value='%s'></td> </tr>\n", $udpport;
61
62 $mcast = &find("mcast", \@conf);
63 print "<tr><td valign=top><b>$text{'conf_mcast'}</b></td> <td colspan=3>\n";
64 printf "<input type=radio name=mcast_def value=1 %s> %s<br>\n",
65         $mcast ? "" : "checked", $text{'conf_none'};
66 printf "<input type=radio name=mcast_def value=0 %s>\n",
67         $mcast ? "checked" : "";
68 @mcast = split(/\s+/, $mcast);
69 $mloop = "<select name=mcast_loop>\n";
70 $mloop .= sprintf "<option value=0 %s>%s\n",
71                 $mcast[4] ? "" : "selected", $text{'conf_disabled'};
72 $mloop .= sprintf "<option value=1 %s>%s\n",
73                 $mcast[4] ? "selected" : "", $text{'conf_enabled'};
74 $mloop .= "</select>\n";
75 print &text('conf_mcastv',
76             "<input name=mcast_dev size=4 value='$mcast[0]'>",
77             "<input name=mcast_ip size=15 value='$mcast[1]'>",
78             "<input name=mcast_port size=5 value='$mcast[2]'>",
79             "<input name=mcast_ttl size=3 value='$mcast[3]'>",
80             $mloop),"</td> </tr>\n";
81
82 $keepalive = &find("keepalive", \@conf);
83 print "<tr> <td><b>$text{'conf_keepalive'}</b></td> <td nowrap>\n";
84 printf "<input type=radio name=keepalive_def value=1 %s> %s\n",
85         $keepalive ? "" : "checked", $text{'default'};
86 printf "<input type=radio name=keepalive_def value=0 %s>\n",
87         $keepalive ? "checked" : "";
88 printf "<input name=keepalive size=6 value='%s'> %s</td>\n",
89         $keepalive, $text{'conf_secs'};
90
91 $deadtime = &find("deadtime", \@conf);
92 print "<tr><td><b>$text{'conf_deadtime'}</b></td> <td nowrap>\n";
93 printf "<input type=radio name=deadtime_def value=1 %s> %s\n",
94         $deadtime ? "" : "checked", $text{'default'};
95 printf "<input type=radio name=deadtime_def value=0 %s>\n",
96         $deadtime ? "checked" : "";
97 printf "<input name=deadtime size=6 value='%s'> %s</td> </tr>\n",
98         $deadtime, $text{'conf_secs'};
99
100 $watchdog = &find("watchdog", \@conf);
101 print "<tr> <td><b>$text{'conf_watchdog'}</b></td> <td colspan=3>\n";
102 printf "<input type=radio name=watchdog_def value=1 %s> %s\n",
103         $watchdog ? "" : "checked", $text{'conf_none'};
104 printf "<input type=radio name=watchdog_def value=0 %s>\n",
105         $watchdog ? "checked" : "";
106 printf "<input name=watchdog size=25 value='%s'> %s</td> </tr>\n",
107         $watchdog, &file_chooser_button("watchdog");
108
109 print "<tr> <td valign=top><b>$text{'conf_node'}</b></td> <td colspan=3>\n";
110 print "<textarea name=node rows=4 cols=40>",
111         join("\n", &find("node", \@conf)),"</textarea></td> </tr>\n";
112
113 $logfile = &find("logfile", \@conf);
114 print "<tr> <td><b>$text{'conf_logfile'}</b></td> <td colspan=3>\n";
115 printf "<input type=radio name=logfile_def value=1 %s> %s\n",
116         $logfile ? "" : "checked", $text{'conf_none'};
117 printf "<input type=radio name=logfile_def value=0 %s>\n",
118         $logfile ? "checked" : "";
119 printf "<input name=logfile size=40 value='%s'> %s</td> </tr>\n",
120         $logfile, &file_chooser_button("logfile");
121
122 $logfacility = &find("logfacility", \@conf);
123 print "<tr> <td><b>$text{'conf_logfacility'}</b></td> <td>\n";
124 printf "<input type=radio name=logfacility_def value=1 %s> %s\n",
125         $logfacility ? "" : "checked", $text{'default'};
126 printf "<input type=radio name=logfacility_def value=0 %s>\n",
127         $logfacility ? "checked" : "";
128 if (&foreign_check("syslog")) {
129         local %sconfig = &foreign_config("syslog");
130         print "<select name=logfacility>\n";
131         foreach $f (split(/\s+/, $sconfig{'facilities'})) {
132                 printf "<option %s>%s\n",
133                         $f eq $logfacility ? "selected" : "", $f;
134                 }
135         print "</select>\n";
136         }
137 else {
138         printf "<input name=logfacility size=15 value='%s'>\n", $logfacility;
139         }
140 print "</td>\n";
141
142 $initdead = &find("initdead", \@conf);
143 print "<tr><td><b>$text{'conf_initdead'}</b></td> <td>\n";
144 printf "<input type=radio name=initdead_def value=1 %s> %s\n",
145         $initdead ? "" : "checked", $text{'default'};
146 printf "<input type=radio name=initdead_def value=0 %s>\n",
147         $initdead ? "checked" : "";
148 printf "<input name=initdead size=6 value='%s'> %s</td> </tr>\n",
149         $initdead, $text{'conf_secs'};
150
151 # changed (Christof Amelunxen, 22.08.2003)
152 # define failback behaviour
153 print "<tr><td><b>$text{'conf_nice_failback'}</b></td> <td>\n";
154 if (&version_atleast(1, 2, 0)) {
155         $auto_failback = &find("auto_failback", \@conf);
156         foreach $aa ("on", "off", "legacy", "") {
157                 printf "<input type=radio name=auto_failback value=%s %s> %s\n",
158                         $aa, $auto_failback eq $aa ? "checked" : "",
159                         $text{'conf_auto_'.$aa};
160                 }
161         }
162 else {
163         $nice_failback = &find("nice_failback", \@conf);
164         printf "<input type=radio name=nice_failback_def value=1 %s> %s\n",
165                 $nice_failback ? "checked" : "", $text{'conf_enabled'};
166         printf "<input type=radio name=nice_failback_def value=0 %s> %s\n",
167                 $nice_failback ? "" : "checked", $text{'conf_disabled'};
168         }
169 print "</td> </tr>\n";
170
171 print "</table></table>\n";
172 print "<input type=submit value='$text{'conf_ok'}'></form>\n";
173
174 &ui_print_footer("", $text{'index_return'});
175