summaryrefslogtreecommitdiffstats
path: root/dhcp_wizard
diff options
context:
space:
mode:
Diffstat (limited to 'dhcp_wizard')
-rwxr-xr-xdhcp_wizard/Dhcp.pm39
1 files changed, 22 insertions, 17 deletions
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 (<OLD>) {
- 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);