Handle hostnames with upper-case letters
[webmin.git] / grub / edit_title.cgi
1 #!/usr/local/bin/perl
2 # edit_title.cgi
3 # Display menu option details
4
5 require './grub-lib.pl';
6 &foreign_require("fdisk", "fdisk-lib.pl");
7 &ReadParse();
8 $conf = &get_menu_config();
9 if ($in{'new'}) {
10         &ui_print_header(undef, $text{'title_add'}, "");
11         }
12 else {
13         &ui_print_header(undef, $text{'title_edit'}, "");
14         $title = $conf->[$in{'idx'}];
15         }
16
17 # Form header
18 print &ui_form_start("save_title.cgi");
19 print &ui_hidden("new", $in{'new'});
20 print &ui_hidden("idx", $in{'idx'});
21 print &ui_table_start($text{'title_header'}, "width=100%", 4);
22
23 # Kernel title
24 print &ui_table_row($text{'title_title'},
25         &ui_textbox("title", $title->{'value'}, 50));
26
27 $r = $title->{'root'} || $title->{'rootnoverify'};
28 if (!$r) {
29         $mode = 0;
30         }
31 elsif ($dev = &bios_to_linux($r)) {
32         $mode = 2;
33         }
34 else {
35         $mode = 1;
36         }
37 $sel = &foreign_call("fdisk", "partition_select", "root", $dev, 2, \$found);
38 if (!$found && $mode == 2) {
39         $mode = 1;
40         }
41
42 # Root partition
43 print &ui_table_row($text{'title_root'},
44         &ui_radio("root_mode", $mode,
45                   [ [ 0, $text{'default'}."<br>" ],
46                     [ 2, $text{'title_sel'}." ".$sel."<br>" ],
47                     [ 1, $text{'title_other'}." ".
48                          &ui_textbox("other",
49                             $mode == 1 ? $title->{'root'} : '', 50) ] ]).
50         "<br>\n".
51         &ui_checkbox("noverify", 1, $text{'title_noverify'},
52                      $title->{'rootnoverify'}), 3);
53
54 # Boot mode
55 $boot = $title->{'chainloader'} ? 1 :
56         $title->{'kernel'} ? 2 : 0;
57 if ($boot == 2) {
58         $title->{'kernel'} =~ /^(\S+)\s*(.*)$/;
59         $kernel = $1; $args = $2;
60         }
61
62 # Booting a kernel
63 @opts = ( );
64 push(@opts, [ 2, $text{'title_kernel'},
65               &ui_table_start(undef, undef, 2, [ undef, "nowrap" ]).
66               &ui_table_row($text{'title_kfile'},
67                 &ui_textbox("kernel", $kernel, 50)." ".
68                 &file_chooser_button("kernel", 0)).
69               &ui_table_row($text{'title_args'},
70                 &ui_textbox("args", $args, 50)).
71               &ui_table_row($text{'title_initrd'},
72                 &ui_opt_textbox("initrd", $title->{'initrd'}, 40,
73                                 $text{'global_none'})).
74               &ui_table_row($text{'title_modules'},
75                 &ui_textarea("module",
76                         join("\n", split(/\0/, $title->{'module'})), 3, 50,
77                         "off")).
78               &ui_table_end() ]);
79
80 # Chain loader
81 $chain = $title->{'chainloader'};
82 push(@opts, [ 1, $text{'title_chain'},
83               &ui_opt_textbox("chain", $chain eq '+1' || !$chain ? '' : $chain,
84                               50, $text{'title_chain_def'}."<br>",
85                               $text{'title_chain_file'})."<br>".
86               &ui_checkbox("makeactive", 1, $text{'title_makeactive'},
87                            defined($title->{'makeactive'})) ]);
88
89 # None (menu entry only)
90 push(@opts, [ 0, $text{'title_none1'}, $text{'title_none2'} ]);
91
92 print &ui_table_row($text{'title_boot'},
93         &ui_radio_table("boot_mode", $boot, \@opts), 3);
94
95 # Lock options
96 print &ui_table_row($text{'title_lock'},
97         &ui_yesno_radio("lock", defined($title->{'lock'})));
98
99 print &ui_table_end();
100 if ($in{'new'}) {
101         print &ui_form_end([ [ undef, $text{'create'} ] ]);
102         }
103 else {
104         print &ui_form_end([ [ undef, $text{'save'} ],
105                              [ 'delete', $text{'delete'} ] ]);
106         }
107
108 &ui_print_footer("", $text{'index_return'});
109