summaryrefslogtreecommitdiffstats
path: root/drakpxelinux.pl
diff options
context:
space:
mode:
Diffstat (limited to 'drakpxelinux.pl')
-rw-r--r--drakpxelinux.pl51
1 files changed, 20 insertions, 31 deletions
diff --git a/drakpxelinux.pl b/drakpxelinux.pl
index 7a66ea5..1700a69 100644
--- a/drakpxelinux.pl
+++ b/drakpxelinux.pl
@@ -106,7 +106,7 @@ my %help = (
sub get_items {
my @items = (
[ "/_File", undef, undef, undef, '<Branch>', ],
- [ "/_File/_Write conf", undef, \&write_conf, 1, '<StockItem>', 'gtk-execute' ],
+ # [ "/_File/_Write conf", undef, \&write_conf, 1, '<StockItem>', 'gtk-execute' ],
[ "/_File/_Exit", undef, sub { ugtk2->exit }, 1, '<StockItem>', 'gtk-quit' ],
[ "/_PXE Server", undef, undef, undef, '<Branch>', ],
@@ -202,7 +202,7 @@ sub update_pxelinux_conf_from_treeview {
server => $server,
directory => $directory,
ramdisk => $ramdisk,
- vga => $network::pxe::vga_bios_to_resolution{$vga},
+ vga => $network::pxe::vga_resolution_to_bios{$vga},
display => $display,
option => $option,
};
@@ -864,19 +864,18 @@ sub create_systems_list() {
N("Profil 2") => 'text',
N("Computer Name") => 'text',
);
+
foreach ($systems->get_columns) { $_->set_resizable(1) }
$systems->set_headers_clickable(1);
+ $systems->set_rules_hint(1);
$systems->get_selection->set_mode('multiple');
-# $systems->get_model->set_sort_column_id(0, 'ascending');
+ $systems->get_model->set_sort_column_id(0, 'ascending');
foreach (0..2) {
$systems->get_column($_)->signal_connect('clicked', \&sort_by_column, $systems->get_model);
$systems->get_column($_)->set_sort_column_id($_ == 0 ? 1 : $_ + 2);
}
- #- don't let the user modify the "Installed" state
$systems->get_column(1)->get_cell_renderers->set_property('mode', 'inert');
$systems->set_column_editable(3, 1);
-# $systems->get_cell_renderers->set_property->signal_connect('clicked', sub { print "here" });
- $systems->set_rules_hint(1);
return $systems;
}
@@ -954,18 +953,6 @@ sub get_profile2_from_mac {
}
}
-sub update_systems_data {
- my ($mac , $name, $profile2, $entry);
- foreach $a (@{$systems->{data}}) {
- $mac = $a->[0];
- $name = $a->[3];
- $profile2 = $a->[2];
- $entry = [ $mac ];
- $profile2 and $a->[2] = $profile2;
- $name and $a->[3] = $name;
- }
-}
-
sub update_systems_data_from_file {
my ($mac , $entry);
foreach $a (@{$systems->{data}}) {
@@ -973,7 +960,6 @@ sub update_systems_data_from_file {
$entry = [ $mac ];
my $profile2 = get_profile2_from_mac($mac);
my $name = get_name_from_mac($mac);
- print "$mac , $profile2 , $name\n";
$profile2 and $a->[2] = $profile2;
$name and $a->[3] = $name;
}
@@ -990,6 +976,17 @@ sub add_configured_mac_addresses() {
}
}
+sub first_get_all_mac {
+ my %addresses;
+ foreach (cat_("/var/log/daemons/info")) {
+ /dhcpd:\s+DHCP(?:DISCOVER|REQUEST).*\s+from\s+($mac_regexp)\b/ and $addresses{$1} = 1;
+ }
+ foreach (keys %addresses) {
+ my $entry = [ $_ ];
+ push @{$systems->{data}}, $entry;
+ }
+}
+
sub get_mac_addresses_from_dhcp_log() {
my %addresses;
foreach (cat_("/var/log/daemons/info")) {
@@ -1045,7 +1042,6 @@ sub add_profile() {
}
sub write_profile_conf {
-# my ($systems) = @_;
my ($mac, $profile, $profile2, $name);
output($conf_mac_profiles_name, "# auto generated by drakpxelinux\n");
foreach $a (@{$systems->{data}}) {
@@ -1053,10 +1049,6 @@ sub write_profile_conf {
}
}
-###############
-# Main Program
-###############
-
sub profile_selected {
my ($profile) = @_;
if ($profile eq 'default') {
@@ -1077,7 +1069,9 @@ sub update_treeview {
set_pxelinux_entry_at_iter($model, $model->append, $_) foreach @{$pxelinux_conf->{entries}};
}
-
+###############
+# Main Program
+###############
# check if first launch
if (!-f ($network::pxe::pxelinux_client_root . "/drakwizard_pxe")) {
info_dialog(N("Please configure a PXE server"), N("It seems this is the first time you run this tool.\nA wizard will appear to configure your PXE server."));
@@ -1099,9 +1093,6 @@ sub launch_pxe_server() {
$::isWizard = 0;
my $w = ugtk2->new(N("Drakpxelinux"));
-#$w->{rwindow}->set_size_request(800, 500) unless $::isEmbedded;
-
-#my $treeview = Gtk2::TreeView->new_with_model($model);
$treeview->set_rules_hint(1);
$treeview->get_selection->set_mode('single');
add_columns($treeview);
@@ -1210,17 +1201,14 @@ gtkpack($w->{window}, gtknew('VBox', spacing => 0, children => [
network::pxe::set_profile_for_mac_address($profile, $to_install, $entry->[0]);
system_entry_set_profile($entry, $profile);
}
- update_systems_data();
write_profile_conf();
}),
gtksignal_connect(gtknew('Button', text => N("Set Profile 2")), clicked => sub {
my $profile = $profiles_combo->get_active_text;
- #my $to_install = exists $profiles_conf->{profiles}{install}{$profile};
foreach ($systems->get_selected_indices) {
my $entry = $systems->{data}[$_];
system_entry_set_profile2($entry, $profile);
}
- update_systems_data();
write_profile_conf();
}),
$profiles_combo = gtknew('ComboBox'),
@@ -1236,6 +1224,7 @@ gtkpack($w->{window}, gtknew('VBox', spacing => 0, children => [
);
add_configured_mac_addresses();
+first_get_all_mac();
update_systems_data_from_file();
get_mac_addresses_from_dhcp_log();
Glib::Timeout->add(60000, \&get_mac_addresses_from_dhcp_log);