summaryrefslogtreecommitdiffstats
path: root/drakpxelinux.pl
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2005-09-02 12:52:09 +0000
committerAntoine Ginies <aginies@mandriva.com>2005-09-02 12:52:09 +0000
commitf25ad975fb8d4df8e9e5343a4688a21796144976 (patch)
tree393a4ebc1812fc8eaea40105e62e16aa4b3c0ca6 /drakpxelinux.pl
parent3e9802ac87c34be16452072d4ed829d60d718c7b (diff)
downloaddrakpxelinux-f25ad975fb8d4df8e9e5343a4688a21796144976.tar
drakpxelinux-f25ad975fb8d4df8e9e5343a4688a21796144976.tar.gz
drakpxelinux-f25ad975fb8d4df8e9e5343a4688a21796144976.tar.bz2
drakpxelinux-f25ad975fb8d4df8e9e5343a4688a21796144976.tar.xz
drakpxelinux-f25ad975fb8d4df8e9e5343a4688a21796144976.zip
now we can clone PXE entry
Diffstat (limited to 'drakpxelinux.pl')
-rw-r--r--drakpxelinux.pl128
1 files changed, 83 insertions, 45 deletions
diff --git a/drakpxelinux.pl b/drakpxelinux.pl
index 70c8f11..17c4118 100644
--- a/drakpxelinux.pl
+++ b/drakpxelinux.pl
@@ -22,7 +22,7 @@
# thx R1 for test and some debug
# cvs.mandrakesoft.com module: /soft/drakpxelinux
-my $version = "1.1.0";
+my $version = "1.2.0";
# i18n: IMPORTANT: to get correct namespace (drakpxelinux instead of libDrakX)
BEGIN { unshift @::textdomains, 'drakpxelinux' }
@@ -42,8 +42,7 @@ use mygtk2 qw(gtknew);
use Gtk2::SimpleList;
use Gtk2::Helper;
use run_program;
-use IO::Socket;
-use Data::Dumper;
+#use Data::Dumper;
our $model = create_model();
our $treeview = Gtk2::TreeView->new_with_model($model);
@@ -176,10 +175,10 @@ foreach (@ARGV) {
}
}
-my ($config_file, $help_file) = $profile && $type ?
- network::pxe::get_pxelinux_profile_path($profile, $type) :
- ($network::pxe::pxelinux_config_file, $network::pxe::pxelinux_help_file);
-my $pxelinux_conf = network::pxe::read_pxelinux_conf($config_file, $help_file);
+my ($config_file, $help_file);# = $profile && $type ?
+# network::pxe::get_pxelinux_profile_path($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 update_pxelinux_conf_from_treeview {
@@ -214,6 +213,7 @@ sub update_pxelinux_conf_from_treeview {
sub write_conf {
+ print "write conf PXE\n";
my ($pxelinux_conf, $treeview) = @_;
update_pxelinux_conf_from_treeview($pxelinux_conf, $treeview);
network::pxe::write_pxelinux_conf($pxelinux_conf, $config_file);
@@ -247,16 +247,18 @@ 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",
- kernel => "LOCALBOOT 0",
- };
- push @{$pxelinux_conf->{entries}}, $entry;
- set_pxelinux_entry_at_iter($model, $model->append, $entry);
+
+sub add_local_profil_entry {
+ my $local_conf = $network::pxe::pxelinux_client_root . "/pxelinux.cfg/profiles/boot/local";
+ if (!-f $local_conf) {
+ output($local_conf, <<EOF);
+PROMPT 10
+DEFAULT local
+TIMEOUT 50
+
+label local
+ LOCALBOOT 0
+EOF
}
}
@@ -327,7 +329,6 @@ sub wizard_add_entry {
};
push @{$pxelinux_conf->{entries}}, $entry;
set_pxelinux_entry_at_iter($model, $model->append, $entry);
-# write_conf();
undef $w;
return;
},
@@ -359,7 +360,7 @@ 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;
+ $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}";
@@ -385,6 +386,39 @@ sub test_similar_label {
} else { return 1 }
}
+sub clone_box_item {
+ my ($_widget, $treeview, $pxelinux_conf) = @_;
+ $::isWizard = 0;
+ my $model = $treeview->get_model;
+ my $iter = $treeview->get_selection->get_selected;
+ if ($iter) {
+ my $path = $model->get_path($iter);
+ my $i = ($path->get_indices)[0];
+ my $entry = $pxelinux_conf->{entries}[$i];
+ my $w = ugtk2->new(N("Clone %s entry", $entry->{label}));
+ my ($entry_box);
+ $w->{window}->set_position('center');
+ $w->{ok_clicked} = sub {
+ my $new_entry = $entry_box->get_text;
+ if ($new_entry !~ m/^\w+$/) { err_dialog(N("Error!"), N("PXE label should be an ASCII word/number without space. Please adjust")) and return }
+ test_similar_label($new_entry, $pxelinux_conf) or return;
+ my $newentry_data = $entry;
+ $newentry_data->{label} = $new_entry;
+ push @{$pxelinux_conf->{entries}}, $newentry_data;
+ set_pxelinux_entry_at_iter($model, $model->append, $newentry_data);
+# write_conf($pxelinux_conf, $treeview);
+ Gtk2->main_quit;
+ };
+ gtkadd($w->{window},
+ gtknew('VBox', children_loose => [
+ $entry_box = gtknew('Entry', text => ''),
+ create_okcancel($w),
+ ])
+ );
+ $w->main;
+ }
+}
+
# dialog box to edit a PXE entry
sub edit_box_item {
my ($_widget, $treeview, $pxelinux_conf) = @_;
@@ -600,7 +634,6 @@ sub edit_box_item {
# update value in cells
set_pxelinux_entry_at_iter($model, $iter, $entry);
- write_conf($pxelinux_conf, $treeview);
$dialog->destroy;
network::pxe::add_in_help($entry->{label}, $entry->{info});
},
@@ -861,8 +894,8 @@ my $profiles_conf = network::pxe::read_profiles();
sub create_systems_list() {
my $systems = Gtk2::SimpleList->new(
N("MAC address") => 'text',
- N("Profil 1") => 'text',
- N("Profil 2") => 'text',
+ N("Boot Profil 1") => 'text',
+ N("Boot Profil 2") => 'text',
N("Computer Name") => 'text',
);
@@ -1013,19 +1046,19 @@ sub refresh_menu {
}
sub add_profile() {
- my $w = ugtk2->new(N("Deployment center"));
- my ($entry, $to_install);
+ my $w = ugtk2->new(N("Add profile"));
+ my ($entry);
+ $w->{window}->set_position('center');
$w->{ok_clicked} = sub {
my $profile = $entry->get_text;
- network::pxe::profile_exists($profiles_conf, $profile) and err_dialog(N("Deployment center"), N("The %s profile already exists!", $profile)), return;
- network::pxe::add_empty_profile($profiles_conf, $profile, $to_install->get_active);
+ network::pxe::profile_exists($profiles_conf, $profile) and err_dialog(N("Add profile"), N("The %s profile already exists!", $profile)), return;
+ network::pxe::add_empty_profile($profiles_conf, $profile); #
refresh_profiles();
Gtk2->main_quit;
};
gtkadd($w->{window},
gtknew('VBox', children_loose => [
- $entry = gtknew('Entry', text => network::pxe::find_next_profile_name($profiles_conf, 'profile')),
- $to_install = gtknew('CheckButton', text => 'This profile needs an installation'),
+ $entry = gtknew('Entry', text => network::pxe::find_next_profile_name($profiles_conf, 'profile_name')),
create_okcancel($w),
]));
$w->main;
@@ -1117,7 +1150,7 @@ my $okcancel = create_okcancel({
# main interface
gtkpack($w->{window}, gtknew('VBox', spacing => 0, children => [
0, $menu,
- if_(!$::isEmbedded, 0, Gtk2::Banner->new('drakgw', N("Drakpxelinux manage your PXE server"))),
+ if_(!$::isEmbedded, 0, Gtk2::Banner->new('IC-Dhost-48', N("Drakpxelinux manage your PXE server"))),
if_($::isEmbedded, 0, Gtk2::Label->new("Here you can manage your PXE server.")),
1, gtknew('Notebook', children => [
gtknew('Label', text => N("PXE configuration file")),
@@ -1130,14 +1163,18 @@ gtkpack($w->{window}, gtknew('VBox', spacing => 0, children => [
0, gtknew('VButtonBox', layout => 'start', children_loose => [
gtksignal_connect(gtknew('Button', text => N("Add profile")), clicked => \&add_profile),
gtksignal_connect(gtknew('Button', text => N("Clone profile")), clicked => sub {
- network::pxe::clone_profile($profiles_conf, $profiles->{data}[$_][0]) foreach $profiles->get_selected_indices;
- refresh_profiles();
- }),
+ foreach ($profiles->get_selected_indices) {
+ $profiles->{data}[$_][0] !~ /local/ ? network::pxe::clone_profile($profiles_conf, $profiles->{data}[$_][0]) : $in->ask_warn(N("Info"), N("No need to clone local profile."));
+ }
+ refresh_profiles();
+ }),
gtksignal_connect(gtknew('Button', text => N("Remove profile")), clicked => sub {
- network::pxe::remove_profile($profiles_conf, $profiles->{data}[$_][0]) foreach $profiles->get_selected_indices;
- refresh_profiles();
- }),
- ]
+ foreach ($profiles->get_selected_indices) {
+ $profiles->{data}[$_][0] !~ /local/ ? network::pxe::remove_profile($profiles_conf, $profiles->{data}[$_][0]) : $in->ask_warn(N("Info"), N("Can't remove local profile."));
+ }
+ refresh_profiles();
+ }),
+ ]
),
0, gtknew('VButtonBox', layout => 'start', children_loose => [
gtknew('Label', text => N("Default boot:")),
@@ -1149,7 +1186,7 @@ gtkpack($w->{window}, gtknew('VBox', spacing => 0, children => [
]
),
0, gtknew('HButtonBox', layout => 'start', children => [
- 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Add an entry")), 'addpxe'), clicked => sub {
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Add a PXE entry")), 'addpxe'), clicked => sub {
my $pxelinux_conf = get_pxelinux_conf_from_profile();
eval { wizard_add_entry($model, $treeview, $pxelinux_conf);
write_conf($pxelinux_conf, $treeview);
@@ -1161,19 +1198,19 @@ gtkpack($w->{window}, gtknew('VBox', spacing => 0, children => [
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 {
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Remove PXE entry")), 'removepxe'), clicked => sub {
my $pxelinux_conf = get_pxelinux_conf_from_profile();
- add_local_entry($model, $treeview, $pxelinux_conf);
+ remove_item($model, $treeview, $pxelinux_conf);
write_conf($pxelinux_conf, $treeview);
}),
- 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Remove Entry")), 'removepxe'), clicked => sub {
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Edit PXE entry")), 'editb'), clicked => sub {
my $pxelinux_conf = get_pxelinux_conf_from_profile();
- remove_item($model, $treeview, $pxelinux_conf);
+ edit_box_item($model, $treeview, $pxelinux_conf);
write_conf($pxelinux_conf, $treeview);
}),
- 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Edit Entry")), 'editb'), clicked => sub {
+ 0, gtksignal_connect(Gtk2::Button->new(N("Clone PXE entry")), clicked => sub {
my $pxelinux_conf = get_pxelinux_conf_from_profile();
- edit_box_item($model, $treeview, $pxelinux_conf);
+ clone_box_item($model, $treeview, $pxelinux_conf);
write_conf($pxelinux_conf, $treeview);
}),
]),
@@ -1184,7 +1221,7 @@ gtkpack($w->{window}, gtknew('VBox', spacing => 0, children => [
1, gtknew('ScrolledWindow', child => $systems),
0, gtknew('HBox',
children_loose => [
- gtksignal_connect(gtknew('Button', text => N("Set Profile 1")), clicked => sub {
+ gtksignal_connect(gtknew('Button', text => N("Set Boot Profile 1")), clicked => sub {
my $profile = $profiles_combo->get_active_text;
my $to_install = exists $profiles_conf->{profiles}{install}{$profile};
foreach ($systems->get_selected_indices) {
@@ -1194,7 +1231,7 @@ gtkpack($w->{window}, gtknew('VBox', spacing => 0, children => [
}
write_profile_conf();
}),
- gtksignal_connect(gtknew('Button', text => N("Set Profile 2")), clicked => sub {
+ gtksignal_connect(gtknew('Button', text => N("Set Boot Profile 2")), clicked => sub {
my $profile = $profiles_combo->get_active_text;
foreach ($systems->get_selected_indices) {
my $entry = $systems->{data}[$_];
@@ -1214,6 +1251,7 @@ gtkpack($w->{window}, gtknew('VBox', spacing => 0, children => [
]),
);
+add_local_profil_entry();
add_configured_mac_addresses();
get_mac_addresses_from_dhcp_log();
update_systems_data_from_file();