summaryrefslogtreecommitdiffstats
path: root/dhcp_wizard
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2004-02-05 15:13:23 +0000
committerAntoine Ginies <aginies@mandriva.com>2004-02-05 15:13:23 +0000
commit816875ca1bd01078fcd617468775a2093781629d (patch)
treee94ca98e53c61e706dec4b89422a6687fe27aed4 /dhcp_wizard
parent334fd1a7c7f9d88f37112782b8069e979e34518a (diff)
downloaddrakwizard-816875ca1bd01078fcd617468775a2093781629d.tar
drakwizard-816875ca1bd01078fcd617468775a2093781629d.tar.gz
drakwizard-816875ca1bd01078fcd617468775a2093781629d.tar.bz2
drakwizard-816875ca1bd01078fcd617468775a2093781629d.tar.xz
drakwizard-816875ca1bd01078fcd617468775a2093781629d.zip
use IPADDR or result of ip sh dev eth0
Diffstat (limited to 'dhcp_wizard')
-rwxr-xr-xdhcp_wizard/Dhcp.pm18
1 files changed, 12 insertions, 6 deletions
diff --git a/dhcp_wizard/Dhcp.pm b/dhcp_wizard/Dhcp.pm
index 1e26dc5b..d3dbccae 100755
--- a/dhcp_wizard/Dhcp.pm
+++ b/dhcp_wizard/Dhcp.pm
@@ -29,7 +29,11 @@ use MDK::Wizard::Varspaceval;
use MDK::Wizard::Wizcommon;
my $wiz = new MDK::Wizard::Wizcommon;
+my $interface = 'eth1';
my $wiz_ip_server = $wiz->{net}->itf_get("IPADDR");
+if (!$wiz_ip_server) {
+ ($wiz_ip_server) = `/sbin/ip addr show dev $interface` =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/m;
+}
my $wiz_tftpserverip = $wiz_ip_server;
my $d = $4 if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
my $s = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
@@ -40,6 +44,7 @@ my $o = {
ip1 => '',
ip2 => '',
pxe => '1',
+ gateway => "$wiz_ip_server",
wiz_authoritative => 0,
einterface => $wiz->{net}->default_itf
},
@@ -64,6 +69,7 @@ $o->{pages} = {
data => [
{ label => N("Lowest IP Address:"), val => \$o->{var}{ip1} },
{ label => N("Highest IP Address:"), val => \$o->{var}{ip2} },
+ { label => N("Gateway IP Address:"), val => \$o->{var}{gateway} },
{ label => N("Enable PXE:"), type => 'bool', val => \$o->{var}{pxe} },
],
next => 'summary'
@@ -106,6 +112,7 @@ $o->{pages} = {
data => [
{ label => N("Lowest IP Address:"), fixed_val => \$o->{var}{ip1} },
{ label => N("Highest IP Address:"), fixed_val => \$o->{var}{ip2} },
+ { label => N("Gateway IP Address:"), fixed_val => \$o->{var}{gateway} },
{ label => N("Interface:"), fixed_val => \$o->{var}{interface} },
{ label => N("Enable PXE:"), fixed_val => \$o->{var}{pxeornot} },
],
@@ -159,16 +166,15 @@ sub check {
sub do_it {
$::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");
+ my $wiz_domain_name = $wiz->{net}->network_get("DOMAINNAME");
+ my $wiz_host_name = $wiz->{net}->network_get("HOSTNAME");
my $wiz_dns = $wiz->{net}->network_get("dnsServer");
if ($wiz_dns eq '127.0.0.1') {
$wiz_dns = $wiz_ip_server
}
- if (!$wiz_gateway) {
+ if (!$o->{var}{gateway}) {
my $t = `LC_ALL=C /sbin/ip route list scope global`;
- ($wiz_gateway) = $t =~ /default via (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) dev/;
+ ($o->{var}{gateway}) = $t =~ /default via (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) dev/;
}
my $wiz_ip_net = "$1.$2.$3.0" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
my $err = check();
@@ -212,7 +218,7 @@ sub do_it {
s|__rng1__|$wiz_ip_range1|g;
s|__rng2__|$wiz_ip_range2|g;
s|__dname__|$wiz_domain_name|g;
- s|__gateway__|$wiz_gateway|g;
+ s|__gateway__|$o->{var}{gateway}|g;
s|__tftpserverip__|$wiz_tftpserverip|g;
$_;
} cat_("__WIZ_HOME__/dhcp_wizard/scripts/dhcpd.conf.default"));