4 require './lilo-lib.pl';
7 &lock_file($config{'lilo_conf'});
8 $conf = &get_lilo_conf();
10 # deleting an existing image
11 $image = $conf->[$in{'idx'}];
12 &save_directive($conf, $image);
14 &unlock_file($config{'lilo_conf'});
15 &webmin_log("delete", "image",
16 &find_value("label", $image->{'members'}), \%in);
21 # creating a new kernel image
22 $image = { 'name' => 'image',
26 # updating an existing image
27 $oldimage = $image = $conf->[$in{'idx'}];
30 # Validate and store inputs
31 $in{'label'} =~ /\S+/ || &error($text{'image_ename'});
32 &save_subdirective($image, "label", $in{'label'});
33 $in{'optional'} || -r $in{'image'} ||
34 &error(&text('image_ekernel', $in{'image'}));
35 $image->{'value'} = $in{'image'};
36 if ($in{'opts'} == 0) {
37 &save_subdirective($image, "append");
38 &save_subdirective($image, "literal");
40 elsif ($in{'opts'} == 1) {
41 &save_subdirective($image, "append", "\"$in{'append'}\"");
42 &save_subdirective($image, "literal");
45 &save_subdirective($image, "append");
46 &save_subdirective($image, "literal", "\"$in{'append'}\"");
48 if ($in{'rmode'} == 0) {
49 &save_subdirective($image, "root");
51 elsif ($in{'rmode'} == 1) {
52 &save_subdirective($image, "root", "current");
54 elsif ($in{'rmode'} == 2) {
55 &save_subdirective($image, "root", $in{'root'});
57 if ($in{'initrd_def'}) {
58 &save_subdirective($image, "initrd");
61 -r $in{'initrd'} || &error(&text('image_einitrd', $in{'initrd'}));
62 &save_subdirective($image, "initrd", $in{'initrd'});
64 &save_subdirective($image, "read-only", $in{'ro'} == 1 ? "" : undef);
65 &save_subdirective($image, "read-write", $in{'ro'} == 2 ? "" : undef);
66 if ($in{'vga'} eq "") {
67 &save_subdirective($image, "vga");
69 elsif ($in{'vga'} eq "other") {
70 $in{'vgaother'} =~ /^\d+$/ ||
71 &error("VGA text mode must be an integer");
72 &save_subdirective($image, "vga", $in{'vgaother'});
75 &save_subdirective($image, "vga", $in{'vga'});
77 if ($in{'passmode'} == 0) {
78 &save_subdirective($image, "password");
81 &save_subdirective($image, "password", $in{'password'});
83 &save_subdirective($image, "restricted", $in{'restricted'} ? "" : undef);
84 &save_subdirective($image, "lock", $in{'lock'} ? "" : undef);
85 &save_subdirective($image, "optional", $in{'optional'} ? "" : undef);
87 # Save the actual image structure
88 &save_directive($conf, $oldimage, $image);
90 &unlock_file($config{'lilo_conf'});
91 &webmin_log($in{'new'} ? 'create' : 'modify', "image",
92 &find_value("label", $image->{'members'}), \%in);