Handle hostnames with upper-case letters
[webmin.git] / lilo / edit_image.cgi
1 #!/usr/local/bin/perl
2 # edit_image.cgi
3 # Edit or create a boot partition
4
5 require './lilo-lib.pl';
6 &foreign_require("fdisk", "fdisk-lib.pl");
7
8 &ReadParse();
9 if ($in{'new'}) {
10         &ui_print_header(undef, $text{'image_title1'}, "");
11         $members = [ ];
12         }
13 else {
14         &ui_print_header(undef, $text{'image_title2'}, "");
15         $conf = &get_lilo_conf();
16         $image = $conf->[$in{'idx'}];
17         $members = $image->{'members'};
18         }
19
20 print "<form action=save_image.cgi>\n";
21 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
22 print "<input type=hidden name=new value='$in{'new'}'>\n";
23 print "<table border width=100%>\n";
24 print "<tr $tb> <td><b>$text{'image_options'}</b></td> </tr>\n";
25 print "<tr $cb> <td><table width=100%>\n";
26
27 print "<tr> <td><b>$text{'image_name'}</b></td>\n";
28 printf "<td><input name=label size=15 value='%s'></td>\n",
29         &find_value("label", $members);
30
31 print "<td><b>$text{'image_kernel'}</b></td>\n";
32 printf "<td><input name=image size=25 value='%s'> %s</td> </tr>\n",
33         $image->{'value'}, &file_chooser_button("image", 0);
34
35 print "<tr> <td><b>$text{'image_opts'}</b></td> <td colspan=3>\n";
36 $append = &find_value("append", $members);
37 $literal = &find_value("literal", $members);
38 $append =~ s/^"(.*)"$/$1/g;
39 $literal =~ s/^"(.*)"$/$1/g;
40 printf "<input type=radio name=opts value=0 %s> $text{'image_default'}\n",
41         $append || $literal ? "" : "checked";
42 printf "<input type=radio name=opts value=1 %s> $text{'image_add'}\n",
43         $append ? "checked" : "";
44 printf "<input type=radio name=opts value=2 %s> $text{'image_replace'}\n",
45         $literal ? "checked" : "";
46 printf "&nbsp; <input name=append size=20 value='%s'></td> </tr>\n",
47         $append ? $append : $literal;
48
49 print "<tr> <td><b>$text{'image_root'}</b></td> <td colspan=3>\n";
50 $root = &find_value("root", $members);
51 printf "<input type=radio name=rmode value=0 %s> $text{'image_fromkern'}\n",
52         $root ? "" : "checked";
53 printf "<input type=radio name=rmode value=1 %s> $text{'image_rcurr'}\n",
54         $root eq "current" ? "checked" : "";
55 printf "<input type=radio name=rmode value=2 %s> $text{'image_rdev'}\n",
56         $root && $root ne "current" ? "checked" : "";
57 print &foreign_call("fdisk", "partition_select",
58                     "root", $root eq "current" ? undef : $root, 0);
59 print "</td> </tr>\n";
60
61 print "<tr> <td><b>$text{'image_initrd'}</b></td> <td colspan=3>\n";
62 $initrd = &find_value("initrd", $members);
63 printf "<input type=radio name=initrd_def value=1 %s> $text{'default'}\n",
64         $initrd ? '' : 'checked';
65 printf "<input type=radio name=initrd_def value=0 %s>\n",
66         $initrd ? 'checked' : '';
67 printf "<input name=initrd size=30 value='%s'> %s</td> </tr>\n",
68         $initrd, &file_chooser_button("initrd");
69
70 $readonly = &find("read-only", $members);
71 $readwrite = &find("read-write", $members);
72 print "<tr> <td><b>$text{'image_mode'}</b></td> <td><select name=ro>\n";
73 printf "<option value=0 %s>$text{'image_fromkern'}\n",
74         $readonly || $readwrite ? "" : "selected";
75 printf "<option value=1 %s>$text{'image_ro'}\n",
76         $readonly ? "selected" : "";
77 printf "<option value=2 %s>$text{'image_rw'}\n",
78         $readwrite ? "selected" : "";
79 print "</select></td>\n";
80
81 $vga = lc(&find_value("vga", $members));
82 print "<td><b>$text{'image_vga'}</b></td>\n";
83 print "<td><select name=vga>\n";
84 printf "<option value='' %s>$text{'image_fromkern'}\n",
85         $vga ? "" : "selected";
86 printf "<option value=normal %s>80x25\n",
87         $vga eq "normal" ? "selected" : "";
88 printf "<option value=ext %s>80x50\n",
89         $vga eq "ext" || $vga eq "extended" ? "selected" : "";
90 printf "<option value=ask %s>$text{'image_ask'}\n",
91         $vga eq "ask" ? "selected" : "";
92 printf "<option value=other %s>$text{'image_other'}\n",
93         $vga =~ /\d/ ? "selected" : "";
94 printf "</select><input name=vgaother size=6 value='%s'></td> </tr>\n",
95         $vga =~ /\d/ ? $vga : "";
96
97 $lock = &find("lock", $members);
98 print "<tr> <td><b>$text{'image_lock'}</b></td> <td>\n";
99 printf "<input type=radio name=lock value=1 %s> $text{'yes'}\n",
100         $lock ? "checked" : "";
101 printf "<input type=radio name=lock value=0 %s> $text{'no'}</td>\n",
102         $lock ? "" : "checked";
103
104 $optional = &find("optional", $members);
105 print "<td><b>$text{'image_optional'}</b></td> <td>\n";
106 printf "<input type=radio name=optional value=1 %s> $text{'yes'}\n",
107         $optional ? "checked" : "";
108 printf "<input type=radio name=optional value=0 %s> $text{'no'}</td> </tr>\n",
109         $optional ? "" : "checked";
110
111 $password = &find_value("password", $members);
112 print "<tr> <td><b>$text{'image_password'}</b></td> <td colspan=3>\n";
113 printf "<input type=radio name=passmode value=0 %s> $text{'image_none'}\n",
114         $password ? "" : "checked";
115 printf "<input type=radio name=passmode value=1 %s>\n",
116         $password ? "checked" : "";
117 print "<input name=password size=25 value=\"$password\"></td> </tr>\n";
118
119 $restricted = &find("restricted", $members);
120 printf "<tr> <td><b>$text{'image_restricted'}</b></td> <td colspan=3>\n";
121 printf "<input type=radio name=restricted value=1 %s> %s\n",
122         $restricted ? "checked" : "", $text{'image_extra'};
123 printf "<input type=radio name=restricted value=0 %s> %s</td> </tr>\n",
124         $restricted ? "" : "checked", $text{'image_any'};
125
126 print "</table></td></tr></table>\n";
127
128 print "<table width=100%><tr>\n";
129 print "<td align=left><input type=submit value=\"$text{'save'}\"></td>\n";
130 if (!$in{'new'}) {
131         print "<td align=right>",
132               "<input type=submit name=delete value=\"$text{'delete'}\"></td>\n";
133         }
134 print "</tr></table></form>\n";
135
136 &ui_print_footer("", $text{'index_return'});
137