Handle hostnames with upper-case letters
[webmin.git] / lilo / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Display all the boot partitions
4
5 require './lilo-lib.pl';
6 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
7         &help_search_link("lilo", "man", "doc", "howto"));
8
9 # Check for non-intel architecture
10 #if (!&is_x86()) {
11 #       print "<p>$text{'index_earch'}<p>\n";
12 #       &ui_print_footer("/", $text{'index'});
13 #       exit;
14 #       }
15
16 # Check if lilo.conf exists
17 if (!-r $config{'lilo_conf'}) {
18         print "<p>",&text('index_econf',
19                           "<tt>$config{'lilo_conf'}</tt>"),"<p>\n";
20         &ui_print_footer("/", $text{'index'});
21         exit;
22         }
23
24 # Get the lilo version
25 $out = `$config{'lilo_cmd'} -V 2>&1`;
26 if ($out =~ /lilo\s+version\s+([0-9\.]+)/i) {
27         $lilo_version = $1;
28         }
29 else {
30         $lilo_version = 1;
31         }
32 open(VERSION, ">$module_config_directory/version");
33 print VERSION $lilo_version,"\n";
34 close(VERSION);
35
36 $conf = &get_lilo_conf();
37 @images = sort { $a->{'index'} <=> $b->{'index'} }
38                ( &find("image", $conf), &find("other", $conf) );
39
40 $default = &find_value("default", $conf);
41 foreach $i (@images) {
42         local $n = $i->{'name'};
43         push(@icons, $n eq "image" ? "images/image.gif" : "images/other.gif");
44         $l = &find_value("label", $i->{'members'});
45         push(@titles, !$default && $i eq $images[0] ? "<b>$l</b>" :
46                       $default && $default eq $l ? "<b>$l</b>" : $l);
47         push(@links, "edit_$n.cgi?idx=$i->{'index'}");
48         }
49 print "<a href='edit_image.cgi?new=1'>$text{'index_addk'}</a> &nbsp;\n";
50 print "<a href='edit_other.cgi?new=1'>$text{'index_addp'}</a><br>\n";
51 &icons_table(\@links, \@titles, \@icons, 4);
52 print "<a href='edit_image.cgi?new=1'>$text{'index_addk'}</a> &nbsp;\n";
53 print "<a href='edit_other.cgi?new=1'>$text{'index_addp'}</a><p>\n";
54 print &ui_hr();
55
56 print "<table width=100%>\n";
57 print "<form action=edit_global.cgi>\n";
58 print "<tr><td><input type=submit value=\"$text{'index_global'}\"></td>\n";
59 print "<td>$text{'index_globalmsg'}</td></tr></form>\n";
60
61 %flang = &load_language('fdisk');
62 $text{'select_part'} = $flang{'select_part'};
63 $text{'select_device'} = $flang{'select_device'};
64 $text{'select_fd'} = $flang{'select_fd'};
65 $dev = &find_value("boot", $conf);
66 print "<form action=apply.cgi>\n";
67 print "<tr><td><input type=submit value=\"$text{'index_apply'}\"></td> <td>\n";
68 if ($dev) {
69         print &text('index_applymsg1',
70           $dev =~ /fd(\d+)$/ ? &text('select_fd', $1) :
71           $dev =~ /hd([a-z])(\d+)$/ ? &text('select_part', 'IDE', uc($1), $2) :
72           $dev =~ /sd([a-z])(\d+)$/ ? &text('select_part', 'SCSI', uc($1), $2) :
73           $dev =~ /hd([a-z])$/ ? &text('select_device', 'IDE', uc($1)) :
74           $dev =~ /sd([a-z])$/ ? &text('select_device', 'SCSI', uc($1)) : $dev);
75         }
76 else {
77         print $text{'index_applymsg2'};
78         }
79 print "\n",$text{'index_applymsg3'},"</td></tr></form>\n";
80 print "</table>\n";
81
82 &ui_print_footer("/", $text{'index'});
83