summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rwxr-xr-xperl-install/standalone/drakgw101
1 files changed, 67 insertions, 34 deletions
diff --git a/perl-install/standalone/drakgw b/perl-install/standalone/drakgw
index fd9862661..bd2a52e4f 100755
--- a/perl-install/standalone/drakgw
+++ b/perl-install/standalone/drakgw
@@ -22,10 +22,12 @@ use c;
local $_ = join '', @ARGV;
-/-h/ and die "usage: drakgw [--expert]\n";
+/-h/ and die "usage: drakgw [--version]\n";
/-v/ and die 'version: $Id$ '."\n";
-$::expert = /-expert/ || cat_("/etc/sysconfig/system") =~ /^TYPE="?expert/m; #"
+# $::expert = /-expert/ || cat_("/etc/sysconfig/system") =~ /^CLASS="?expert/m; #"
+# $::expert and print "Running in expert mode.\n" and sleep 1;
+
$::isStandalone = 1;
my $in = vnew interactive('su');
@@ -33,7 +35,7 @@ my $in = vnew interactive('su');
my $sysconf_network = "/etc/sysconfig/network";
my $conf_linuxconf = "/etc/conf.linuxconf";
-my $rc_firewall = "/etc/rc.d/rc.firewall";
+my $rc_firewall = "/etc/rc.d/rc.firewall.inet_sharing";
my $dhcpd_conf = "/etc/dhcpd.conf";
@@ -44,7 +46,7 @@ sub start_daemons()
grep(/is running/, `/etc/rc.d/init.d/dhcpd status`) and ((system("/etc/rc.d/init.d/dhcpd stop") == 0) or die "Could not stop the dhcp server");
grep(/Connection refused/, `/etc/rc.d/init.d/named status 2>&1`) or ((system("/etc/rc.d/init.d/named stop") == 0) or die "Could not stop the named server");
(system("/etc/rc.d/init.d/network restart") == 0) or die "Could not restart the network";
- (system("/etc/rc.d/rc.firewall") == 0) or die "Could not start the firewall script";
+ (system("sh /etc/rc.d/rc.firewall") == 0) or die "Could not start the firewall script";
(system("/etc/rc.d/init.d/named start") == 0) or die "Could not start the caching nameserver";
(system("/sbin/chkconfig --level 345 named on") == 0) or die "Could not chkconfig named";
(system("/etc/rc.d/init.d/dhcpd start") == 0) or die "Could not start the dhcp server";
@@ -139,13 +141,17 @@ $in->ask_okcancel(_("Internet Connection Sharing"),
#($#pci_ethernet_cards == -1) and $in->ask_warn('', _("No PCI network ethernet devices found!")) and $in->exit(0);
#
## push @pci_ethernet_cards, [ "NETWORK_ETHERNET", "Fake ne2000", "ne2k" ];
-#
-#my @configured_devices = map { /ifcfg-(\S+)/; $1 } `ls /etc/sysconfig/network-scripts/ifcfg*`;
-#
+
+my @configured_devices = map { /ifcfg-(\S+)/; $1 } `ls /etc/sysconfig/network-scripts/ifcfg*`;
+
#my @active_devices = `/sbin/ifconfig | grep ^[a-z] | awk '{print \$1}'`; chop @active_devices;
my %aliased_devices; (/^alias\s+(eth[0-9])\s+(\S+)/) and ($aliased_devices{$1} = $2) foreach (`cat /etc/modules.conf`);
-my @all_cards = map { "Interface $_ (using module $aliased_devices{$_})" } (keys %aliased_devices);
+my @cards_to_ignore = (); #= @{netconnect::configured_devices};
+log::l("Information from netconnect: ignoring card $_\n") foreach (@cards_to_ignore);
+my @all_cards;
+foreach my $dev (keys %aliased_devices)
+ { grep(/$dev/,@cards_to_ignore) or (push @all_cards, "Interface $dev (using module $aliased_devices{$dev})") };
# print "pci_detection: "; print ">".$_->[2]."< " foreach (@pci_ethernet_cards);
@@ -178,19 +184,19 @@ my $interface;
if ($#all_cards == -1)
{
$in->ask_warn(_("No network adapter on your system!"),
- _("No ethernet network adapter is currently configured on your system. Please run the hardware configuration tool."));
+ _("No ethernet network adapter has been detected on your system. Please run the hardware configuration tool."));
$in->exit(0);
}
elsif ($#all_cards == 0)
{
$interface = $all_cards[0];
- $in->ask_okcancel(_("Network interface"),
- _("There is only one configured network adapter on your system:\n\n$interface\n\nWould you like to setup your Local Area Network with that adapter?"), 1) or $in->exit(0);
+# $::expert and $in->ask_okcancel(_("Network interface"),
+# _("There is only one configured network adapter on your system:\n\n$interface\n\nWould you like to setup your Local Area Network with that adapter?"), 1) or $in->exit(0);
}
else
{
$interface = $in->ask_from_list(_("Choose the network interface"),
- _("Please choose what network adapter will be connected\nto your Local Area Network."),
+ _("Please choose what network adapter will be connected to your Local Area Network."),
\@all_cards,
);
defined $interface or $in->exit(0);
@@ -198,22 +204,23 @@ else
$interface =~ /(eth[0-9]+)/ or die("Internal error");
my $device = $1;
+grep(/$device/, @configured_devices) and
+ ($in->ask_okcancel('', _("Warning, the network adapter is already configured.\nWould you like to reconfigure?")) or $in->exit(0));
+
#- setup the address for the LAN
-my $lan_address = "192.168.0.0";
-$::expert and ($lan_address = $in->ask_from_entry(_("Local Area Network specification"),
- _("You may now decide which class C network to use.\n"),
- _("Network:"), $lan_address,
- ) or $in->exit(0));
-($lan_address =~ /^([0-9]+\.[0-9]+\.[0-9]+)\.0$/) or die "Invalid network.\n";
-$lan_address = $1;
+my $full_lan_address = "192.168.0.0";
+#$::expert and ($full_lan_address = $in->ask_from_entry(_("Local Area Network specification"),
+# _("You may now decide which class C network to use.\n"),
+# _("Network:"), $full_lan_address,
+# ) or $in->exit(0));
+($full_lan_address =~ /^([0-9]+\.[0-9]+\.[0-9]+)\.0$/) or die "Invalid network.\n";
+my $lan_address = $1;
#- test for potential conflict with other networks
-my @configured_devices = map { /ifcfg-(\S+)/; $1 } `ls /etc/sysconfig/network-scripts/ifcfg-*`;
-
foreach (@configured_devices)
{
if ($_ ne $device)
@@ -222,21 +229,27 @@ foreach (@configured_devices)
my $ifcfg = "/etc/sysconfig/network-scripts/ifcfg-$_";
open IFCFG, "$ifcfg" or die "Can't open $ifcfg";
my @ifcfg_content = <IFCFG>;
- grep(/$lan_address/, @ifcfg_content) and $in->ask_warn('', _("Potential LAN address conflict found in current config of $_!\n")) and $in->exit(0);
+ grep(/$lan_address/, @ifcfg_content) and
+ $in->ask_warn('', _("Potential LAN address conflict found in current config of $_!\n")) and $in->exit(0);
close IFCFG;
}
}
-#- ask for confirmation
+#- test for potential conflict with previous firewall config
+
+my @chain_rules;
+(-f "/etc/sysconfig/ipchains" or ((-x "/sbin/ipchains") and (@chain_rules = `/sbin/ipchains -L`) and ($#chain_rules > 2)))
+ and ($in->ask_okcancel(_("Firewalling configuration detected!"),
+ _("Warning! An existing firewalling configuration has been detected. You may need some manual fix after installation. Proceed?"), 1) or $in->exit(0));
-$in->ask_okcancel(_("Internet Connection Sharing - setup of $device"),
- _("The following interface is about to be configured:\n\n$interface\n\n".
- "It will be setup on a Local Area Network ($lan_address.0); additionnally, IP forwarding ".
- "and masquerading will be enabled, together with a DHCP server.\n".
- "You will then be able to connect other computers to this network, with automatic ".
- "DHCP configuration."), 1) or $in->exit(0);
+#- ask for confirmation
+#
+#$in->ask_okcancel(_("Internet Connection Sharing - setup"),
+# _("The local network is about to be configured.\n") .
+# "You will then be able to connect other computers to this network, with automatic ".
+# "DHCP configuration."), 1) or $in->exit(0);
#- **********************************
@@ -268,6 +281,30 @@ my $f = "/sbin/ipchains";
-e $f or system("urpmi --auto ipchains");
-e $f or ($in->ask_warn('', _("Could not install ipchains RPM with urpmi.")) and $in->exit(0));
+if (-f "/etc/rc.d/rc.firewall")
+{
+ local *RCFIREWALL;
+ open RCFIREWALL, "/etc/rc.d/rc.firewall" or die "Can't open /etc/rc.d/rc.firewall";
+ my @rcfirewall_content = <RCFIREWALL>;
+ close RCFIREWALL;
+ grep(/\/etc\/rc\.d\/rc\.firewall\.inet_sharing/, @rcfirewall_content) or push @rcfirewall_content, "# Added by drakgw\n[ -x /etc/rc.d/rc.firewall.inet_sharing ] && /etc/rc.d/rc.firewall.inet_sharing\n";
+ open RCFIREWALL, ">/etc/rc.d/rc.firewall" or die "Can't open /etc/rc.d/rc.firewall";
+ print RCFIREWALL @rcfirewall_content;
+ close RCFIREWALL;
+}
+else
+{
+ local *RCFIREWALL; open RCFIREWALL, ">/etc/rc.d/rc.firewall" or die "Can't open /etc/rc.d/rc.firewall";
+ print RCFIREWALL <<EOF;
+#!/bin/sh
+#
+# Automatically generated by drakgw
+
+[ -x /etc/rc.d/rc.firewall.inet_sharing ] && /etc/rc.d/rc.firewall.inet_sharing
+EOF
+ chmod 0700, "/etc/rc.d/rc.firewall";
+}
+
-f $rc_firewall and rename($rc_firewall, "$rc_firewall.old");
local *RCFIREWALL; open RCFIREWALL, ">$rc_firewall" or die "Can't open $rc_firewall";
print RCFIREWALL <<EOF;
@@ -448,11 +485,7 @@ start_daemons();
undef $wait_configuring;
--f "/etc/sysconfig/ipchains" and $in->ask_warn(_("Firewalling configuration detected.!"),
- _("Warning! An existing firewalling configuration has been detected.\n".
- "It will probably override forwarding and masquerading configuration, please fix."));
-
-$in->ask_warn(_("Everything configured!"),
+$in->ask_warn(_("Congratulations!"),
_("Everything has been configured.\n".
"You may now share Internet connection with other computers on your Local Area Network, ".
"using automatic network configuration (DHCP)."));
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266
#!/usr/bin/perl
#
# Copyright (C) 2004-2005 by Mandriva aginies _ateuh_ mandriva.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

# Quick configuration of PXE menu parameters
# thx R1 for test and some debug
# svn.mandriva.com/svn/soft/drakpxelinux


# i18n: IMPORTANT: to get correct namespace (drakpxelinux instead of libDrakX)
BEGIN { unshift @::textdomains, 'drakpxelinux' }

use lib qw(/usr/lib/libDrakX);
use standalone;
use strict;
use common;
use services;
use network::network;
use network::pxe;
use network::tools;
use interactive;
# must come *after* definition of textdomains for proper initialisation
use ugtk3 qw(:ask :helpers :wrappers :create :dialogs);
use mygtk3 qw(gtknew);
use Gtk3::SimpleList;
use Gtk3::Helper;
use run_program;
use Data::Dumper;

our $model = create_model();
our $treeview = Gtk3::TreeView->new_with_model($model);

# ie of entry menu in PXE:
#label linux
#        KERNEL images/vmlinuz
#        APPEND initrd=images/all.rdz automatic=method:http,interface:eth0,network:dhcp,server:10.0.1.33,directory:/install/ ramdisk_size=64000 root=/dev/ram3 rw vga=788 display=:0

# default VAR
my $SYSLINUXPATH = '/usr/lib/syslinux/';
my $MEMDISK = $SYSLINUXPATH . '/memdisk';
my $XINETDDIR = "/etc/xinetd.d";
my $conf_mac_profiles_name = "/var/lib/tftpboot/X86PC/conf_mac_profiles";

my $net = {};
network::network::read_net_conf($net);

my $sys_wizard_pxe = "/etc/sysconfig/drak_pxe";
my ($interface) = cat_($sys_wizard_pxe) =~ /INTERFACE=(.*)/;
$interface ||= $net->{net_interface};
link_default_path();

my $help = "" .
N("PXE Label: the name to be displayed in the PXE menu (an ASCII word/number)") . "\n" .
N("Server: IP address of server, that contains the installation directory") . "\n" .
N("Kernel: memdisk or vmlinuz") . "\n" .
N("Initrd: network boot image (network.img) or all.rdz") . "\n" .
N("Interface: network interface used for the installation process") . "\n" .
N("Network: DHCP or an IP address") . "\n" .
N("Directory: full path to Mageia install server directory") . "\n" .
N("Installation method: NFS or HTTP") . "\n" .
N("Ramsize: ramsize parameter on boot image") . "\n" .
N("Display: export display to another computer (e.g.: 10.0.1.33:0)") . "\n" .
N("VGA: if you encounter any problem with VGA, please adjust") . "\n" .
"";


my %help = (
	    'initrd' => N("network boot image (network.img) or all.rdz"),
	    'kernel' => N("memdisk in case of network.img, or vmlinuz"),
	    'vga' => N("if you encounter any problem with VGA, please adjust"),
	    'interface' => N("network interface used for the installation process"),
	    'info' => N("Information displayed in PXE help (F1 key)"),
	    'network' => N("DHCP or an IP address"),
	    'directory' => N("full path to Mageia install server directory"),
	    'automatic' => N("installation method: choose NFS or HTTP"),
	    'ramsize' => N("ramsize parameter on boot image"),
	    'display' => N("export display on another computer (e.g.: 10.0.1.33:0)"),
	    'other' => "apic nolapic acpi=off initrd=/bin/shell",
	    'server' => N("IP address of server, that contains the installation directory"),
	    'labels' => N("lists all PXE entries, the default boot is the selected one"),
	    'wizardsrv' => N("launches a wizard to setup a PXE server"),
	    'editb' => N("edits the PXE entry selected with a dialog box"),
	    'removepxe' => N("removes the selected PXE entry"),
	    'apply' => N("apply change to configuration file"),
	    'addpxe' => N("launches a wizard to add a PXE entry "),
	    'helponline' => N("get help from online documentation"),
	    'auto_install' => "http://your_ip:3712/auto_<profil>_<label>.pl",
	   );

sub get_items {
    my @items = (
                 [ "/_File", undef, undef, undef, '<Branch>', ],
        #         [ "/_File/_Write conf", undef, \&write_conf, 1, '<StockItem>', 'gtk-execute' ],
                 [ "/_File/_Exit", undef, sub { ugtk3->exit }, 1, '<StockItem>', 'gtk-quit' ],

                 [ "/_PXE Server", undef, undef, undef, '<Branch>', ],
                 [ "/_PXE Server/_Restart", undef, \&restart_dialog, 1, '<StockItem>', 'gtk-execute' ],
		 [ "/_PXE Server/_Reconfigure", undef, sub {
		     eval { wizard_pxe_server() };
		     my $err = $@;
		     $::WizardWindow->destroy if defined $::WizardWindow;
		     undef $::WizardWindow;
		     if ($err && $err !~ /wizcancel/) {
		       err_dialog(N("Error"), N("The PXE server wizard has unexpectedly failed:")
				  . "\n\n" . $err);
		     }
		   }, 1, '<StockItem>', 'gtk-execute' ],

		 [ "/_Help/Help", undef, \&show_help, 1, '<StockItem>', 'gtk-help' ],
                 );
    return @items;
}

my $in = 'interactive'->vnew('su');

sub restart_dialog {
    my $cmd = "service pxe restart";
    my $w = $in->wait_message(N("PXE server"), N("Restarting PXE server..."));
    run_program::get_stdout($cmd) !~ /unknown|error/ or err_dialog(N("Error!"), N("Error Restarting PXE server")) and return;
    undef $w;
}

sub set_help_tip {
  my ($entry, $key) = @_;
  gtkset_tip($entry, formatAlaTeX($help{$key}));
}

if (!$::testing && !$in->do_pkgs->ensure_is_installed('pxe', $network::pxe::pxe_config_file)) {
    err_dialog(N("Error!"), N("missing %s\n\nPlease install the pxe package.", $network::pxe::pxe_config_file));
    $in->exit(-1);
}

save_config($network::pxe::pxelinux_config_file);

my @list_method = qw(nfs http ka dolly); push @list_method, "";
my @list_ram = qw(32000 48000 64000 96000 128000);
my @list_eth = qw(auto eth0 eth1 eth2); push @list_eth, "";

use constant COLUMN_LABEL => 0;
use constant COLUMN_INFO => 1;
use constant COLUMN_KERNEL => 2;
use constant COLUMN_INITRD => 3;
use constant COLUMN_METHOD => 4;
use constant COLUMN_INTERFACE => 5;
use constant COLUMN_NETWORK => 6;
use constant COLUMN_SERVER => 7;
use constant COLUMN_DIRECTORY => 8;
use constant COLUMN_RAMDISK_SIZE => 9;
use constant COLUMN_VGA => 10;
use constant COLUMN_DISPLAY => 11;
use constant COLUMN_OTHERS => 12;
use constant COLUMN_AUTO_INSTALL => 13;
use constant NUM_COLUMNS => 14;

my ($profile, $type);
foreach (@ARGV) {
    if (/^--profile=(\w+)$/) {
	$profile = $1;
    } elsif (/^--type=(\w+)$/) {
	$type = $1;
    }
}

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 link_default_path() {
  # need to quick fix pb of duplicate default (network::pxe need various adjustement).
  if (!-f "$network::pxe::pxelinux_client_root/pxelinux.cfg/profiles/boot/default") {
    mkdir_p("$network::pxe::pxelinux_client_root/pxelinux.cfg/profiles/boot/");
    system("ln -sf $network::pxe::pxelinux_config_file  $network::pxe::pxelinux_client_root/pxelinux.cfg/profiles/boot/default");
  }
}


sub update_pxelinux_conf_from_treeview {
  my ($pxelinux_conf, $treeview) = @_;
  my $profile = get_selected_profile();
  ($config_file, $help_file) = network::pxe::get_pxelinux_profile_path($profile, 'boot');
  my $model = $treeview->get_model;
  my $iter = $model->get_iter_first;
  splice @{$pxelinux_conf->{entries}};
  while ($iter) {
    my ($label, $info, $kernel, $initrd, $method, $interface, $network, $server, $directory, $ramdisk_size, $vga, $display, $others, $auto_install) = $model->get($iter, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
    my $entry = {
                 label => $label,
                 info => $info,
                 kernel => $kernel,
                 initrd => $initrd,
                 method => $method,
                 interface => $interface,
                 network => $network,
                 server => $server,
                 directory => $directory,
                 ramdisk_size => $ramdisk_size,
                 vga => $network::pxe::vga_resolution_to_bios{$vga},
                 display => $display,
                 others => $others,
		 auto_install => $auto_install,
                };
    if  ($entry->{label} eq "local") {
      $entry = {
		label => "local",
		localboot => "0",
	       };
      push @{$pxelinux_conf->{entries}}, $entry;
    } else {
      push @{$pxelinux_conf->{entries}}, $entry;
    }
    last if !$model->iter_next($iter);
  }
}



sub write_conf {
  my ($pxelinux_conf, $treeview) = @_;
  update_pxelinux_conf_from_treeview($pxelinux_conf, $treeview);
  if (basename($config_file) ne "local") {
    #print "write conf PXE\n";
    network::pxe::write_pxelinux_conf($pxelinux_conf, $config_file);
  }
}

sub set_pxelinux_entry_at_iter {
    my ($model, $iter, $entry) = @_;
    $model->set($iter,
		 COLUMN_LABEL, $entry->{label},
		 COLUMN_INFO, $entry->{info},
		 COLUMN_KERNEL, $entry->{kernel},
		 COLUMN_INITRD, $entry->{initrd},
		 COLUMN_METHOD, $entry->{method},
		 COLUMN_INTERFACE, $entry->{interface},
		 COLUMN_NETWORK, $entry->{network},
		 COLUMN_SERVER, $entry->{server},
		 COLUMN_DIRECTORY, $entry->{directory},
		 COLUMN_RAMDISK_SIZE, $entry->{ramdisk_size},
		 COLUMN_VGA, $network::pxe::vga_bios_to_resolution{$entry->{vga}},
		 COLUMN_DISPLAY, $entry->{display},
		 COLUMN_OTHERS, $entry->{others},
		COLUMN_AUTO_INSTALL, $entry->{auto_install},
	       );
}


sub create_model() {
#    my $model = Gtk3::ListStore->new(("Glib::String") x NUM_COLUMNS);
  my $model = Gtk3::ListStore->new("Glib::String", "Glib::String",  "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String");
#  set_pxelinux_entry_at_iter($model, $model->append, $_) foreach @{$pxelinux_conf->{entries}};
  set_pxelinux_entry_at_iter($model, $model->append, $_) foreach @{$pxelinux_conf->{entries}};
  return $model;
}


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
  }
}

# wizard to add an entry in PXE menu
sub wizard_add_entry {
  my ($_widget, $treeview, $pxelinux_conf, $profiles) = @_;
  my $model = $treeview->get_model;

  local $::isEmbedded = 0;
  undef $::WizardTable;
  undef $::WizardWindow;
  $::isWizard = 1;
  use wizards;
  my $WPXENAME = "Mageia";
  my $WINFO = "install Mageia";
  my $WALLRDZ = "/mnt/nfs/isolinux/alt0/all.rdz";
#  my $WALLRDZ = "/tmp/all.rdz";
  my $WVMLINUZ = "/mnt/nfs/isolinux/alt0/vmlinuz";
#  my $WVMLINUZ = "/tmp/vmlinuz";
  my $wiz = wizards->new({
	     name => N("Add a PXE entry"),
	     pages => {
		       welcome => {
				   name => N("Add an all.rdz boot image") . "\n" . N("To boot through the network, the networked computer needs a boot image. Morever we need to name this image, so each boot image is related to a name in the PXE menu. Thus, the user can choose which image he wants to boot through PXE.") . "\n\n" . N("For technical reasons, in case of multiple boot images, it's simpler to boot the networked computer through a kernel (vmlinuz), and to provide one file with all needed drivers (in our case all.rdz)."),
				   next => 'addimg',
				   no_back => 1,
				  },
		       addimg => {
				  name => N("When this wizard has finished, the all.rdz image and kernel vmlinuz will be copied into \n%s.\n\nThe PXE menu list will be updated with this new entry.", $network::pxe::pxelinux_images),
				  data => [
					   { label => N("PXE label:"), val => \$WPXENAME,
					     help => N("name displayed in PXE menu (please provide an ASCII word or a number, without spaces)") },
					   { label => N("PXE information:"), val => \$WINFO,
					     help => N("The PXE information is used to explain the role of the boot image,\ne.g.:\nMageia rescue disk\nMageia cauldron install via http") },
					   { label => N("Full path to all.rdz image source:"), type => 'file', val => \$WALLRDZ,
					     help => N("Provide the full path to all.rdz image location") },
					   { label => N("Full path to vmlinuz source:"), type => 'file', val => \$WVMLINUZ,
					     help => N("Provide the full path to vmlinuz kernel location") },
					  ],
				  complete => sub {
				    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';
				    }
				    if (! -f $WALLRDZ) {
				      err_dialog(N("Error!"), N("Please enter a correct path to all.rdz")) and return 'addimg';
				    }
				    if (! -f $WVMLINUZ) {
				      err_dialog(N("Error!"), N("Please enter a correct path to vmlinuz")) and return 'addimg';
				    }
				  },
				  next => 'endadd',
				  post => sub {