Handle hostnames with upper-case letters
[webmin.git] / pserver / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Display a table of icons for cvs server options
4
5 require './pserver-lib.pl';
6 &ReadParse();
7
8 if (!$cvs_path) {
9         &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
10         print "<p>",&text('index_ecvs', "<tt>$config{'cvs'}</tt>",
11                   "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
12         &ui_print_footer("/", $text{'index'});
13         exit;
14         }
15
16 $ver = &get_cvs_version(\$out);
17 if (!$ver) {
18         &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
19         print "<p>",&text('index_eversion', "<tt>$config{'cvs'} -v</tt>",
20                           "<pre>$out</pre>"),"<p>\n";
21         &ui_print_footer("/", $text{'index'});
22         exit;
23         }
24
25 # Go direct to one icon, if it is the only one available
26 @avfeatures = grep { $access{$_} } @features;
27 if (@avfeatures == 1 && !$access{'setup'}) {
28         &redirect($featureprog{$avfeatures[0]});
29         exit;
30         }
31
32 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, undef,
33         &help_search_link("cvs", "man", "doc"), undef, undef,
34         &text('index_version', $ver));
35
36 if (!-d "$config{'cvsroot'}/CVSROOT") {
37         # No CVS root .. offer to setup
38         print "<p>",&text('index_eroot',
39                 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
40
41         if ($access{'init'}) {
42                 print &text('index_initdesc',
43                             "<tt>$config{'cvsroot'}</tt>"),"<p>\n";
44                 print "<form action=init.cgi>\n";
45                 print "<input type=submit value='$text{'index_init'}'>\n";
46                 print "</form>\n";
47                 }
48
49         &ui_print_footer("/", $text{'index'});
50         exit;
51         }
52
53 # Show configuration icons
54 @icons = map { "images/$_.gif" } @avfeatures;
55 @links = map { $featureprog{$_} } @avfeatures;
56 @titles = map { $text{$_."_title"} } @avfeatures;
57 &icons_table(\@links, \@titles, \@icons, 4);
58
59 if ($access{'setup'}) {
60         # Check if run from inetd or xinetd
61         print &ui_hr();
62         print "<table width=100%><tr>\n";
63         $inet = &check_inetd();
64         if ($inet && $inet->{'args'} =~ /\s(\/\S+)\s+pserver$/) {
65                 $inetdir = $1;
66                 }
67         if (!$inet) {
68                 print "<form action=setup.cgi>\n";
69                 print "<td><input type=submit value='$text{'index_setup'}'></td>\n";
70                 print "<td>",&text('index_setupdesc',
71                    $has_xinetd ? "<tt>xinetd</tt>" : "<tt>inetd</tt>"),"<br>\n";
72                 print "<b>$text{'index_asuser'}</b>\n";
73                 print &ui_user_textbox("user", "root"),"\n";
74                 print "</td>\n";
75                 print "</form>\n";
76                 }
77         elsif (!$inet->{'active'}) {
78                 print "<form action=setup.cgi>\n";
79                 print "<td><input type=submit value='$text{'index_act'}'></td>\n";
80                 if ($inetdir) {
81                         print "<td>",&text('index_actdesc2',
82                                 "<tt>$inet->{'type'}</tt>",
83                                 "<tt>$inetdir</tt>");
84                         }
85                 else {
86                         print "<td>",&text('index_actdesc',
87                                 "<tt>$inet->{'type'}</tt>");
88                         }
89                 print "<br>\n";
90                 print "<b>$text{'index_asuser'}</b>\n";
91                 print &ui_user_textbox("user", $inet->{'user'}),"\n";
92                 print "</td>\n";
93                 print "</form>\n";
94                 }
95         else {
96                 print "<form action=setup.cgi>\n";
97                 print "<td><input type=submit value='$text{'index_deact'}'></td>\n";
98                 if ($inetdir) {
99                         print "<td>",&text('index_deactdesc2',
100                                 "<tt>$inet->{'type'}</tt>",
101                                 "<tt>$inetdir</tt>"),"</td>\n";
102                         }
103                 else {
104                         print "<td>",&text('index_deactdesc',
105                                 "<tt>$inet->{'type'}</tt>"),"</td>\n";
106                         }
107                 print "</form>\n";
108                 }
109         print "</tr></table>\n";
110         if ($inetdir && $inetdir ne $config{'cvsroot'}) {
111                 print "<p><center><b>$text{'index_einetroot'}</b></center>\n";
112                 }
113         }
114
115 &ui_print_footer("/", $text{'index'});
116