Handle hostnames with upper-case letters
[webmin.git] / cfengine / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Display main menu of cfengine options
4
5 require './cfengine-lib.pl';
6
7 # Check if cfengine command exists
8 if (!&has_command($config{'cfengine'})) {
9         &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
10         print &text('index_ecommand', "<tt>$config{'cfengine'}</tt>",
11                      "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
12         &ui_print_footer("/", $text{'index'});
13         exit;
14         }
15
16 # Make sure it is actually cfengine, and get the version
17 $ver = &get_cfengine_version(\$out);
18 if (!$ver) {
19         &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
20         print &text('index_eversion', "<tt>$config{'cfengine'} -v</tt>",
21                      "<pre>$out</pre>"),"<p>\n";
22         &ui_print_footer("/", $text{'index'});
23         exit;
24         }
25
26 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, undef,
27         &help_search_link("cfengine", "man", "doc", "google"), undef, undef,
28         &text('index_version', $ver));
29
30 # Only versions 1.x are supported yet
31 if ($ver !~ /^1\./) {
32         print &text('index_eversion2', "<tt>$config{'cfengine'}</tt>",
33                      "<tt>$ver</tt>", "<tt>1.x</tt>"),"<p>\n";
34         &ui_print_footer("/", $text{'index'});
35         exit;
36         }
37
38 # Check if config file exists
39 if (!-r $cfengine_conf || -d $config{'cfengine_conf'}) {
40         print &text('index_econfig', "<tt>$cfengine_conf</tt>",
41                   "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
42         &ui_print_footer("/", $text{'index'});
43         exit;
44         }
45
46 # Display table of sections
47 $conf = &get_config();
48 @secs = grep { $_->{'type'} eq 'section' } @$conf;
49 &show_classes_table(\@secs, 0);
50
51 # Display option icons
52 print &ui_hr();
53 print &ui_subheading($text{'index_options'});
54 @links = ( "run_form.cgi", "list_hosts.cgi", "edit_cfd.cgi", "edit_push.cgi" );
55 @titles = ( $text{'run_title'}, $text{'hosts_title'}, $text{'cfd_title'},
56             $text{'push_title'} );
57 @icons = ( "images/run.gif", "images/hosts.gif", "images/cfd.gif",
58            "images/push.gif" );
59 &icons_table(\@links, \@titles, \@icons);
60
61 &ui_print_footer("/", $text{'index'});
62