summaryrefslogtreecommitdiffstats
path: root/dns_wizard
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2004-10-26 09:00:14 +0000
committerAntoine Ginies <aginies@mandriva.com>2004-10-26 09:00:14 +0000
commitdeac970ee71f5e26560b5e919d62455942aac6e0 (patch)
treefbcbe001e1be86327c1afa203cfbede538f10b6c /dns_wizard
parent4d18f317ec1818d9b57d7f99d496115095ca90f5 (diff)
downloaddrakwizard-deac970ee71f5e26560b5e919d62455942aac6e0.tar
drakwizard-deac970ee71f5e26560b5e919d62455942aac6e0.tar.gz
drakwizard-deac970ee71f5e26560b5e919d62455942aac6e0.tar.bz2
drakwizard-deac970ee71f5e26560b5e919d62455942aac6e0.tar.xz
drakwizard-deac970ee71f5e26560b5e919d62455942aac6e0.zip
now support multiple interface
Diffstat (limited to 'dns_wizard')
-rw-r--r--dns_wizard/Bind.pm65
1 files changed, 38 insertions, 27 deletions
diff --git a/dns_wizard/Bind.pm b/dns_wizard/Bind.pm
index 2c931ab1..8a324abd 100644
--- a/dns_wizard/Bind.pm
+++ b/dns_wizard/Bind.pm
@@ -28,23 +28,24 @@ use MDK::Wizard::Varspaceval;
use MDK::Wizard::Wizcommon;
-#unless ($> == 0) {
-# die "You are not root Exiting\n";
-#}
-
my $wiz = new MDK::Wizard::Wizcommon;
-
my $SERIAL = chomp_(`date +%d%m20%y`);
my $HOSTNAME = $wiz->{net}->network_get("HOSTNAME");
-my $interface = 'eth0';
+
+
my $IPSERVER = $wiz->{net}->itf_get("IPADDR");
-if (!$IPSERVER) {
+my $sys_wizard_dns = "/etc/sysconfig/drak_dns_wiz";
+if (-f $sys_wizard_dns) {
+ our ($interface) = cat_($sys_wizard_dns) =~ /INTERFACE=(.*)/;
+ ($IPSERVER) = `/sbin/ip addr show dev $interface` =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/m;
+} else {
+ our $interface = "eth0";
($IPSERVER) = `/sbin/ip addr show dev $interface` =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/m;
}
-#my $DOMAINNAME = $wiz->{net}->network_get("DOMAINNAME");
-my $DOMAINNAME = chomp_(`dnsdomainname`);
+my $DOMAINNAME = chomp_(`dnsdomainname`);
+my $CLIENTIP = get_spe_ip("ipnor", $IPSERVER) . ".";
my $WDIR = "/tmp/dnstest";
my $NAMED_DIR = "/var/named";
my $DNSKEY = "";
@@ -53,8 +54,6 @@ my $TEXTINFO = "dns Wizard";
my $REP_SAVE = "/tmp/bck";
my $ZONE_DIR = $NAMED_DIR . "/zone";
my $DATE = `date +%d-%m-20%y`;
-my $ft = "/etc/sysconfig/wizard_dns";
-
my $o = {
name => 'DNS Configuration Wizard',
@@ -65,7 +64,7 @@ my $o = {
SHORTHOSTNAME => $SHORTHOSTNAME,
IPMASTER => '',
CLIENTNAME => '',
- CLIENTIP => '',
+ CLIENTIP => $CLIENTIP,
},
needed_rpm => [ 'bind' ],
defaultimage => "/usr/share/wizards//dns_wizard/images/DNS.png",
@@ -74,7 +73,7 @@ my $o = {
return 0, N("You need to readjust your hostname.")
}
if (member($DOMAINNAME, qw(localdomain (none)))) {
- return 0, N("You need to readjust your domainname. For a DNS server you need a correct domainname, not equal to localdomain or none. Hostname must be a FQDN: Fully Qualified Domain Name. Launch drakconnect to adjust it.")
+ return 0, N("You need to readjust your domainname. For a DNS server you need a correct domainname, not equal to localdomain or none. Hostname mut be a FQDN: Fully Qualified Domain Name. Launch drakconnect to adjust it.")
}
1
},
@@ -112,20 +111,30 @@ $o->{pages} = {
if ($o->{var}{wiz_level} == 2) {
return 'slave' }
elsif ($o->{var}{wiz_level} == 1) {
- return 'ipforward' }
+ return 'interface' }
elsif ($o->{var}{wiz_level} == 3) {
- if (-f $ft) { return 'addhost' } else { return 'error_notmaster' } }
+ if (-f $sys_wizard_dns) { return 'addhost' } else { return 'error_notmaster' } }
elsif ($o->{var}{wiz_level} == 4) {
- if (-f $ft) { return 'removehost' } else { return 'error_notmaster' } }
+ if (-f $sys_wizard_dns) { return 'removehost' } else { return 'error_notmaster' } }
},
data => [
{ label => N("What do you want to do:"), val => \$o->{var}{wiz_level}, list => [ keys %level ], format => sub { $level{$_[0]} } },
],
- next => 'ipforward',
+ next => 'interface',
},
+ interface => {
+ name => N("DNS server Interface"),
+ data => [
+ { list => [ keys %{$wiz->{net}{itf}} ], val => \$o->{var}{interface} },
+ ],
+ no_back => 1,
+ next => 'ipforward'
+ },
addhost => {
name => N("Client identification:") . "\n\n" . N("Your client on the network will be identified by name, as in clientname.company.net. Every machine on the network must have a (unique) IP address, in the usual dotted syntax.") . "\n\n" . N("(You don't need to add the domain after the name)") . "\n\n" . N("Note that the given IP address and client name should be unique in the network."),
data => [
+ { label => N("Server:"), fixed_val => \$o->{var}{SHORTHOSTNAME} },
+ { label => N("DNS Domainname:"), fixed_val => \$o->{var}{DOMAINNAME} },
{ label => N("Name of the machine:"), val => \$o->{var}{CLIENTNAME} },
{ label => N("IP address of the machine:"), val => \$o->{var}{CLIENTIP} },
],
@@ -151,6 +160,10 @@ $o->{pages} = {
ipforward => {
name => N("IP of your forwarder") . "\n\n" . N("Forwarding occurs on only those queries for which the server is not authoritative and does not have the answer in its cache.") . "\n\n" . N("If you need it and know your IP forwarder enter IP address of it, if you dont know leave it blank"),
+ pre => sub {
+ ($IPSERVER) = `/sbin/ip addr show dev $o->{var}{interface}` =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/m;
+ output($sys_wizard_dns, "INTERFACE=$o->{var}{interface}\n");
+ },
data => [
{ label => N("External DNS:"), val => \$o->{var}{IPOFFORWARDER} },
],
@@ -216,6 +229,8 @@ $o->{pages} = {
summaryadd => {
name => N("Client with this identification will be added to your DNS"),
data => [
+ { label => N("Server:"), fixed_val => \$o->{var}{SHORTHOSTNAME} },
+ { label => N("DNS Domainname:"), fixed_val => \$o->{var}{DOMAINNAME} },
{ label => N("Computer name:"), fixed_val => \$o->{var}{CLIENTNAME} },
{ label => N("Computer IP address:"), fixed_val => \$o->{var}{CLIENTIP} },
],
@@ -243,13 +258,9 @@ $o->{pages} = {
},
endadd => {
name => N("Congratulations"),
- data => [ { label => N("The wizard successfully added the host in your DNS.") } ],
- post => sub {
- $o->{var}{CLIENTNAME} = '';
- $o->{var}{CLIENTIP} = '';
- },
+ data => [ { label => N("The wizard successfully add host in your DNS.") } ],
no_back => 1,
- next => 'addhost',
+ next => 0,
},
endremove => {
name => N("Congratulations"),
@@ -321,7 +332,6 @@ sub increment_serial {
my ($iprev) = @_;
my ($SERIAL) = cat_("$ZONE_DIR/db.$DOMAINNAME.hosts") =~ m/\s+(.*?)\s+;\s+Serial/;
$SERIAL = chomp_($SERIAL+1);
- print "$SERIAL\n";
substInFile {
s/\s+\d+\s+;\s+Serial/ $SERIAL ; Serial/;
} "$ZONE_DIR/db.$DOMAINNAME.hosts";
@@ -588,7 +598,8 @@ sub save_old_config {
}
if (-d "$REP_SAVE/dns") { rm_rf("$REP_SAVE/dns") }
mkdir_p($REP_SAVE . '/dns');
- cp_af($_, "$REP_SAVE/dns/$_" . '-' . $DATE . '.sauv') foreach glob_($ZONE_DIR . "/*");
+ system("cp -avf $ZONE_DIR/* $REP_SAVE/dns/");
+# cp_af($_, "$REP_SAVE/dns/$_" . '-' . $DATE . '.sauv') foreach glob_($ZONE_DIR . "/*");
if (-e "/etc/named.conf") {
cp_af("/etc/named.conf", "$REP_SAVE/dns/named.conf-$DATE");
}
@@ -705,7 +716,7 @@ sub do_it_master {
return if $::testing;
my $in = 'interactive'->vnew('su', 'dns');
my $w = $in->wait_message(N("Master DNS server"), N("Configuring your system as Master DNS server ..."));
- system("touch $ft");
+ output($sys_wizard_dns, "INTERFACE=$o->{var}{interface}\n");
do_it();
crea_iprev($IPSERVER, $DOMAINNAME);
crea_ipnorm($IPSERVER, $DOMAINNAME);
@@ -719,7 +730,7 @@ sub do_it_slave {
return if $::testing;
my $in = 'interactive'->vnew('su', 'dns');
my $w = $in->wait_message(N("Slave DNS server"), N("Configuring your system as Slave DNS server ..."));
- if (-f $ft) { unlink $ft }
+ if (-f $sys_wizard_dns) { unlink $sys_wizard_dns }
do_it();
rm_rf(glob("$NAMED_DIR/bak*"));
crea_named_slave($IPSERVER, $DOMAINNAME, $o->{var}{IPMASTER});