Handle hostnames with upper-case letters
[webmin.git] / pap / list_mgetty.cgi
1 #!/usr/local/bin/perl
2 # list_mgetty.cgi
3 # Displays a list of serial ports on which mgetty is enabled by searching
4 # for them in /etc/inittab
5
6 require './pap-lib.pl';
7 $access{'mgetty'} || &error($text{'mgetty_ecannot'});
8 &foreign_require("inittab", "inittab-lib.pl");
9 &ui_print_header(undef, $text{'mgetty_title'}, "");
10
11 if (!&has_command($config{'mgetty'})) {
12         print "<p>",&text('mgetty_ecmd', "<tt>$config{'mgetty'}</tt>"),"<p>\n";
13         &ui_print_footer("", $text{'index_return'});
14         exit;
15         }
16 print &text('mgetty_desc', "<tt>mgetty</tt>"),"<p>\n";
17
18 @mgi = &mgetty_inittabs();
19 if (@mgi) {
20         print "<a href='edit_mgetty.cgi?new=1'>$text{'mgetty_add'}</a><br>\n";
21         print "<table border>\n";
22         print "<tr $tb> <td><b>$text{'mgetty_tty'}</b></td> ",
23               "<td><b>$text{'mgetty_type'}</b></td> ",
24               "<td><b>$text{'mgetty_speed'}</b></td> ",
25               "<td><b>$text{'mgetty_answer'}</b></td> ",
26               "<td><b>$text{'mgetty_config'}</b></td> </tr>\n";
27         foreach $m (@mgi) {
28                 print "<tr $cb>\n";
29                 local $tty = $m->{'tty'} =~ /^ttyS(\d+)$/ ?
30                         &text('mgetty_ts', $1+1) :
31                         $m->{'tty'} =~ /^term\/(\S+)$/ ?
32                         &text('mgetty_ts', uc($1)) :
33                         $m->{'tty'} =~ /^\// ? $m->{'tty'} : "/dev/$m->{'tty'}";
34                 if ($m->{'mgetty'}) {
35                         print "<td><a href='edit_mgetty.cgi?id=$m->{'id'}'>",
36                               "$tty</a></td>\n";
37                         print "<td>",$m->{'direct'} ? $text{'mgetty_direct'}
38                                             : $text{'mgetty_modem'},"</td>\n";
39                         print "<td>",$m->{'speed'} ||
40                                      $text{'mgetty_auto'},"</td>\n";
41                         print "<td>",defined($m->{'rings'}) ? $m->{'rings'}
42                                             : 1," $text{'mgetty_rings'}</td>\n";
43                         local $fn = $m->{'tty'};
44                         $fn =~ s/^\/dev\///;
45                         $fn =~ s/\//\./g;
46                         if ($access{'options'}) {
47                                 print "<td><a href='edit_options.cgi?",
48                                       "file=$config{'ppp_options'}.$fn'>",
49                                       "$text{'mgetty_cedit'}</a></td>\n";
50                                 }
51                         else {
52                                 print "<td><br></td>\n";
53                                 }
54                         }
55                 else {
56                         print "<td>$tty</td>\n";
57                         print "<td colspan=4>$text{'mgetty_vgetty'}</td>\n";
58                         }
59                 print "</tr>\n";
60                 }
61         print "</table>\n";
62         }
63 else {
64         print "<b>$text{'mgetty_none'}</b><p>\n";
65         }
66 print "<a href='edit_mgetty.cgi?new=1'>$text{'mgetty_add'}</a><p>\n";
67
68 print &ui_hr();
69 print "<form action=mgetty_apply.cgi>\n";
70 print "<table width=100%><tr>\n";
71 print "<td><input type=submit value='$text{'mgetty_apply'}'></td>\n";
72 print "<td>",&text('mgetty_applydesc', "<tt>telinit q</tt>"),"</td>\n";
73 print "</tr></table></form>\n";
74
75 &ui_print_footer("", $text{'index_return'});
76