summaryrefslogtreecommitdiffstats
path: root/drakpxelinux.pl
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2005-08-30 09:05:28 +0000
committerAntoine Ginies <aginies@mandriva.com>2005-08-30 09:05:28 +0000
commitc2807287f5329f6791a61a6b74d12b432b0e9ccd (patch)
tree41fef8c8641c39281c8dff48c38d7328cd3e0463 /drakpxelinux.pl
parentf9aa790b199eda9e20015a65c83c488603f4d74a (diff)
downloaddrakpxelinux-c2807287f5329f6791a61a6b74d12b432b0e9ccd.tar
drakpxelinux-c2807287f5329f6791a61a6b74d12b432b0e9ccd.tar.gz
drakpxelinux-c2807287f5329f6791a61a6b74d12b432b0e9ccd.tar.bz2
drakpxelinux-c2807287f5329f6791a61a6b74d12b432b0e9ccd.tar.xz
drakpxelinux-c2807287f5329f6791a61a6b74d12b432b0e9ccd.zip
enable instant change do not loose modification in profile (otherwise it will be a pain to use this tool)
Diffstat (limited to 'drakpxelinux.pl')
-rw-r--r--drakpxelinux.pl69
1 files changed, 45 insertions, 24 deletions
diff --git a/drakpxelinux.pl b/drakpxelinux.pl
index a42f733..1850675 100644
--- a/drakpxelinux.pl
+++ b/drakpxelinux.pl
@@ -182,8 +182,9 @@ my ($config_file, $help_file) = $profile && $type ?
($network::pxe::pxelinux_config_file, $network::pxe::pxelinux_help_file);
my $pxelinux_conf = network::pxe::read_pxelinux_conf($config_file, $help_file);
-sub write_conf() {
- network::pxe::write_pxelinux_conf($pxelinux_conf, $config_file);
+sub write_conf {
+ my ($pxelinux_conf) = @_;
+ network::pxe::write_pxelinux_conf($pxelinux_conf, $config_file);
}
sub set_pxelinux_entry_at_iter {
@@ -214,9 +215,21 @@ sub create_model() {
return $model;
}
+sub add_local_entry {
+ my ($_widget, $treeview, $pxelinux_conf) = @_;
+ my $model = $treeview->get_model;
+ if (test_similar_label("local", $pxelinux_conf)) {
+ my $entry = {
+ label => "local",
+ };
+ push @{$pxelinux_conf->{entries}}, $entry;
+ set_pxelinux_entry_at_iter($model, $model->append, $entry);
+ }
+}
+
# wizard to add an entry in PXE menu
sub wizard_add_entry {
- my ($_widget, $treeview) = @_;
+ my ($_widget, $treeview, $pxelinux_conf) = @_;
my $model = $treeview->get_model;
local $::isEmbedded = 0;
@@ -252,7 +265,7 @@ sub wizard_add_entry {
help => N("Provide the full path to vmlinuz kernel location") },
],
complete => sub {
- test_similar_label($WPXENAME) or return 'addimg';
+ test_similar_label($WPXENAME, $pxelinux_conf) or return 'addimg';
if (($WPXENAME) !~ /^\w+$/) {
err_dialog(N("Error!"), N("PXE label should be an ASCII word/number without space. Please adjust")) and return 'addimg';
}
@@ -303,7 +316,7 @@ sub wizard_add_entry {
# remove an entry in PXE menu
sub remove_item {
- my ($_widget, $treeview) = @_;
+ my ($_widget, $treeview, $pxelinux_conf) = @_;
$::isWizard = 0;
my $model = $treeview->get_model;
my $selection = $treeview->get_selection;
@@ -313,13 +326,13 @@ sub remove_item {
my $i = ($path->get_indices)[0];
my $entry = $pxelinux_conf->{entries}[$i];
- $entry->{label} =~ /local/ and info_dialog(N("Local"), N("You can't remove local entry.")) and return 0;
- ask_okcancel("Remove $entry->{label} PXE entry ?") or return;
+ # $entry->{label} =~ /local/ and info_dialog(N("Local"), N("You can't remove local entry.")) and return 0;
+ ask_okcancel("Info", "Remove $entry->{label} PXE entry ?") or return;
network::pxe::remove_in_help($entry->{label});
my $ke = $network::pxe::pxelinux_client_root . "/$entry->{kernel}";
my $initrdf = $network::pxe::pxelinux_client_root . "/$entry->{initrd}";
- if (basename($entry->{kernel} ne $network::pxe::pxelinux_client_root . "/memdisk")) {
- print "k: $ke\n";
+ if (basename($entry->{kernel} ne "memdisk")) {
+ print "kernel: $ke\n";
print "initrd: $initrdf\n";
system("rm -vf $ke");
system("rm -vf $initrdf");
@@ -329,12 +342,11 @@ sub remove_item {
}
$model->remove($iter);
splice @{$pxelinux_conf->{entries}}, $i, 1;
-# write_conf();
}
}
sub test_similar_label {
- my ($label) = @_;
+ my ($label, $pxelinux_conf) = @_;
if (any { $_->{label} eq $label } @{$pxelinux_conf->{entries}}) {
err_dialog(N("Error!"), N("Found a similar entry in PXE list labeled: %s.\nChoose another label please", $label)) and return 0;
} else { return 1 }
@@ -556,7 +568,6 @@ sub edit_box_item {
# update value in cells
set_pxelinux_entry_at_iter($model, $iter, $entry);
$dialog->destroy;
-# write_conf();
network::pxe::add_in_help($entry->{label}, $entry->{info});
},
},
@@ -645,7 +656,6 @@ sub cell_edited {
$entry->{option} = $new_text;
$model->set($iter, $column, $entry->{option});
}
-# write_conf();
}
sub show_help() { info_dialog("help",
@@ -819,7 +829,6 @@ sub create_systems_list() {
N("MAC address") => 'text',
N("Installed") => 'bool',
N("Profil 1") => 'text',
- N("Profil 2") => 'text',
N("Computer Name") => 'text',
);
foreach ($systems->get_columns) { $_->set_resizable(1); }
@@ -832,7 +841,7 @@ sub create_systems_list() {
}
#- don't let the user modify the "Installed" state
$systems->get_column(1)->get_cell_renderers->set_property('mode', 'inert');
- $systems->set_column_editable(4, 1);
+ $systems->set_column_editable(3, 1);
$systems->set_rules_hint(1);
return $systems;
}
@@ -862,9 +871,11 @@ my $log_text = gtknew('TextView');
sub get_pxelinux_conf_from_profile() {
my $model_profiles = $profiles->get_model;
my $iter = $profiles->get_selection->get_selected;
- ($config_file, $help_file) = network::pxe::get_pxelinux_profile_path($model_profiles->get($iter, 0), 'boot');
- my $pxelinux_conf = profile_selected($model_profiles->get($iter, 0));
- return $pxelinux_conf;
+ if ($iter) {
+ ($config_file, $help_file) = network::pxe::get_pxelinux_profile_path($model_profiles->get($iter, 0), 'boot');
+ my $pxelinux_conf = profile_selected($model_profiles->get($iter, 0));
+ return $pxelinux_conf;
+ }
}
sub system_entry_set_profile { my ($entry, $profile) = @_; $entry->[2] = $profile || N("None") }
@@ -943,7 +954,6 @@ sub profile_selected {
# force type = boot
my $type = "boot";
($config_file, $help_file) = network::pxe::get_pxelinux_profile_path($profile, $type);
- print "----- $config_file $help_file\n";
undef $pxelinux_conf;
}
my $pxelinux_conf = network::pxe::read_pxelinux_conf($config_file, $help_file);
@@ -992,7 +1002,6 @@ my $defaultlabel = $pxelinux_conf->{default};
$labelscombo->entry->set_text($defaultlabel);
$labelscombo->entry->signal_connect("changed", sub {
$pxelinux_conf->{default} = $labelscombo->entry->get_text;
-# write_conf();
});
my @o = network::pxe::list_pxelinux_labels($pxelinux_conf);
@@ -1019,7 +1028,9 @@ my $menu = $factory->get_widget('<main>');
my $okcancel = create_okcancel({
cancel_clicked => sub { ugtk2->exit },
- ok_clicked => sub { write_conf; ugtk2->exit },
+ ok_clicked => sub {
+ write_conf(get_pxelinux_conf_from_profile());
+ ugtk2->exit },
},
);
@@ -1054,7 +1065,9 @@ gtkpack($w->{window},
0, gtknew('HButtonBox', layout => 'start', children => [
0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Add PXE entry")), 'addpxe'), clicked => sub {
my $pxelinux_conf = get_pxelinux_conf_from_profile();
- eval { wizard_add_entry($model, $treeview, $pxelinux_conf) };
+ eval { wizard_add_entry($model, $treeview, $pxelinux_conf);
+ write_conf($pxelinux_conf);
+ };
my $err = $@;
$::WizardWindow->destroy if defined $::WizardWindow;
undef $::WizardWindow;
@@ -1062,12 +1075,20 @@ gtkpack($w->{window},
err_dialog(N("Error"), N("The PXE entry wizard has unexpectedly failed:") . "\n\n" . $err);
}
}),
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Add PXE local")), 'addpxe'), clicked => sub {
+ my $pxelinux_conf = get_pxelinux_conf_from_profile();
+ add_local_entry($model, $treeview, $pxelinux_conf)
+ }),
0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Remove")), 'removepxe'), clicked => sub {
my $pxelinux_conf = get_pxelinux_conf_from_profile();
- remove_item($model, $treeview, $pxelinux_conf) }),
+ remove_item($model, $treeview, $pxelinux_conf);
+ write_conf($pxelinux_conf);
+ }),
0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Edit")), 'editb'), clicked => sub {
my $pxelinux_conf = get_pxelinux_conf_from_profile();
- edit_box_item($model, $treeview, $pxelinux_conf) }),
+ edit_box_item($model, $treeview, $pxelinux_conf);
+ write_conf($pxelinux_conf);
+ }),
#gtknew('Label', text => N("Default boot:")),
#1, $labelscombo,
]