From e4371f18753c98687f71de82810acc79428c51f9 Mon Sep 17 00:00:00 2001 From: Florent Villard Date: Fri, 5 Sep 2003 11:42:20 +0000 Subject: *** empty log message *** --- dhcp_wizard/Dhcp.pm | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'dhcp_wizard/Dhcp.pm') diff --git a/dhcp_wizard/Dhcp.pm b/dhcp_wizard/Dhcp.pm index ba9b71d1..b8168450 100755 --- a/dhcp_wizard/Dhcp.pm +++ b/dhcp_wizard/Dhcp.pm @@ -34,9 +34,11 @@ my $o = { name => N('DHCP Wizard'), var => { ip1 => '', - ip2 => '' + ip2 => '', + interface => $wiz->{net}->default_itf() }, - needed_rpm => [ 'dhcp-server' ] + needed_rpm => [ 'dhcp-server' ], + defaultimage => "$ENV{__WIZ_HOME__}dhcp_wizard/images/DHCP.png" }; $o->{pages} = { @@ -54,12 +56,21 @@ $o->{pages} = { }, post => \&check, data => [ - { label => '' }, { label => N('Lowest IP Address:'), val => \$o->{var}{ip1} }, { label => N('Highest IP Address:'), val => \$o->{var}{ip2} }, ], next => 'summary' }, + interface => { + name => N('Interface the dhcp server must listen to'), + pre => sub { + $o->{var}{interface} ||= $wiz->{net}->default_itf() + }, + data => [ + { list => [ keys %{$wiz->{net}{itf}} ], val => \$o->{var}{interface} }, + ], + next => 'summary' + }, dhcp_warning => { name => N('Warning'), data => [ { label => N('You are in dhcp, server may not work with your configuration.') } ], @@ -84,8 +95,8 @@ $o->{pages} = { name => N('Configuring the DHCP Server') . "\n\n" . N('The wizard collected the following parameters needed to configure your DHCP service:'), data => [ { label => N('Lowest IP Address:'), fixed_val => \$o->{var}{ip1} }, - { label => '' }, { label => N('Highest IP Address:'), fixed_val => \$o->{var}{ip2} }, + { label => N('Interface:'), fixed_val => \$o->{var}{interface} }, ], post => \&do_it, next => 'end' @@ -129,11 +140,12 @@ sub check { } if (!$d1 || !$d2 || $d1 > $d2) { standalone::explanations("DHCP wizard : bad range"); return 'ip_range_error'} if ($ds >= $d1 && $ds <= $d2) { standalone::explanations("DHCP wizard : server in range"); return 'server_in_range'} + return 'interface' if keys %{$wiz->{net}{itf}} > 1; 0 } sub do_it { - $::DEBUG and return; + $::testing and return; my $wiz_domain_name = $wiz->{net}->network_get("DOMAINNAME"); my $wiz_host_name = $wiz->{net}->network_get("HOSTNAME"); my $wiz_gateway = $wiz->{net}->network_get("GATEWAY"); @@ -151,7 +163,7 @@ sub do_it { my $wiz_ip_range1 = $o->{var}{ip1}; my $wiz_ip_range2 = $o->{var}{ip2}; my $wiz_ip_netmask = $wiz->{net}->itf_get("NETMASK"); - my $wiz_device = $wiz->{net}->default_itf(); + my $wiz_device = $o->{var}{interface}; # patch to rewrite when got new file about dhcp with INTERFACES value # currently, I put the device to configure as dhcp server # in /etc/sysconfig/dhcpd @@ -159,25 +171,18 @@ sub do_it { #[ -f /etc/sysconfig/dhcpd ] && cp -f /etc/sysconfig/dhcpd /var/tmp/wiz_bck/orig/dhcpd my $file = "/etc/sysconfig/dhcpd"; -f $file and MDK::Common::cp_af($file, $file.".orig"); - - $file = "/etc/rc.d/init.d/dhcpd"; -# now patching etc/rc.d/init.d/dhcpd - standalone::explanations("now patching etc/rc.d/init.d/dhcpd"); + standalone::explanations("now patching etc/sysconfig/dhcpd"); if (!`grep INTERFACES $file`){ - MDK::Common::append_to_file($file, "\nINTERFACES=$wiz_device"); - MDK::Common::cp_af($file, $file . ".orig"); my $tmp = `/bin/mktemp /tmp/Dhcpconf.XXXXXX` or die "can't make a temp file: $!"; open(NEW, "> $tmp") or die "can't open $tmp: $!"; open(OLD, "< $file") or die "can't open default: $!"; while () { - if (m|daemon\s*/usr/sbin/dhcp|) { - print NEW "\tif [ -f /etc/sysconfig/dhcpd ]; then -\t\t. /etc/sysconfig/dhcpd -\t\tDEV=\$INTERFACES -\tfi\n"; + if (m|INTERFACE|) { + print NEW "# $_"; } print NEW $_; } + MDK::Common::append_to_file($tmp, "\n# Added by drakwizard\nINTERFACES=$wiz_device"); close(OLD); close(NEW); chomp($tmp); -- cgit v1.2.1