diff options
Diffstat (limited to 'dns_wizard')
-rw-r--r-- | dns_wizard/Bind.pm | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/dns_wizard/Bind.pm b/dns_wizard/Bind.pm index ce59d3a3..88ecad9d 100644 --- a/dns_wizard/Bind.pm +++ b/dns_wizard/Bind.pm @@ -55,7 +55,7 @@ my $DATE = `date +%d-%m-20%y`; my $o = { name => 'DNS Configuration Wizard', - var => { + var => { IPOFFORWARDER => '', ADDSEARCH => '', DOMAINNAME => $DOMAINNAME, @@ -110,7 +110,7 @@ $o->{pages} = { return 'removehost' } }, data => [ - { label => N("What Kind of DNS :"), val => \$o->{var}{wiz_level}, list => [ keys %level ], format => sub { $level{$_[0]} } }, + { label => N("What do you want todo:"), val => \$o->{var}{wiz_level}, list => [ keys %level ], format => sub { $level{$_[0]} } }, ], next => 'ipforward', }, @@ -124,7 +124,7 @@ $o->{pages} = { next => 'summaryadd', }, removehost => { - name => N('Remove Host') . "\n\n" . N('Remove a host in existing dns configuration.') . "\n\n" . N('Choose the host you want to remove in the following list.'), + name => N('Remove host:') . "\n\n" . N('Remove a host in existing dns configuration.') . "\n\n" . N('Choose the host you want to remove in the following list.'), data => [ { label => N("Name of the machine:"), val => \$o->{var}{CLIENTNAME}, fixed_list => \@list_hosts }, ], @@ -134,25 +134,25 @@ $o->{pages} = { slave => { name => N('Slave DNS server') . "\n\n" . N("A slave name server will take some of the burden away from your primary name server, and will also function as a backup server, in case your master server is unreachable."), data => [ - { label => N('IP of master DNS server'), val => \$o->{var}{IPMASTER} }, + { label => N('IP of master DNS server:'), val => \$o->{var}{IPMASTER} }, ], post => \&check_ipm, next => 'summaryslave', }, error_hostname => { - name => N('You need to readjust your hostname'), + name => N('You need to readjust your hostname.'), end => 1, next => 0, }, error_domain => { - name => N('You need to readjust your domainame'), + name => N('You need to readjust your domainame.'), end => 1, next => 0, }, ipforward => { name => N('IP of your forwarders') . "\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('So if you need it and know your ip forwarder enter IP address of it, if you dont know leave it blank'), data => [ - { label => N('IP forwarders'), val => \$o->{var}{IPOFFORWARDER} }, + { label => N('IP forwarders:'), val => \$o->{var}{IPOFFORWARDER} }, ], post => \&check_ipf, next => 'addsearch', @@ -160,22 +160,22 @@ $o->{pages} = { addsearch => { name => N('Add search domain') . "\n\n" . N('Search list for host-name lookup. The search list is normally determined from the local domain name; by default, it contains only the local domain name. This may be changed by listing the desired domain search path following the search keyword') . "\n\n" . N('Domainname of this server is automatically added, and you dont need to add it here.'), data => [ - { label => N('add search domain'), val => \$o->{var}{ADDSEARCH} }, + { label => N('add search domain:'), val => \$o->{var}{ADDSEARCH} }, ], next => 'summary', }, error_ipf => { - name => N('Error IP of forwarder') . "\n\n" . N('This is not a valid IP address for your forwarder... press next to continue'), + name => N('Error IP of forwarder.') . "\n\n" . N('This is not a valid IP address for your forwarder... press next to continue'), ignore => 1, next => 'ipforward', }, error_ipm => { - name => N('Error Ip of DNS master') . "\n\n" . N('This is not a valid Master DNS IP address... press next to continue'), + name => N('Error Ip of DNS master.') . "\n\n" . N('This is not a valid Master DNS IP address... press next to continue'), ignore => 1, next => 'slave', }, error_iph => { - name => N('Error Ip of new host') . "\n\n" . N('This is not a valid IP address... press next to continue'), + name => N('Error Ip of new host.') . "\n\n" . N('This is not a valid IP address... press next to continue'), ignore => 1, next => 'addhost', }, @@ -185,19 +185,29 @@ $o->{pages} = { next => 'client_id' }, error_add => { - name => N('Error add host') . "\n\n" . N('It seems that host is already in your DNS configuration... press next to continue'), + name => N('Error add host.') . "\n\n" . N('It seems that host is already in your DNS configuration... press next to continue'), ignore => 1, next => 'addhost', }, error_remove => { - name => N('Error remove host') . "\n\n" . N('It seems that this is not present in your DNS configuration... press next to continue'), + name => N('Error remove host.') . "\n\n" . N('It seems that this is not present in your DNS configuration... press next to continue'), ignore => 1, next => 'removehost', }, + error_nosrv => { + name => N("It seems that no DNS server has been set through wizard. Please run DNS wizard: Master DNS server."), + next => 0, + end => 1, + }, + error_notmaster => { + name => N("It seems that your are not a master DNS server, but just a slave one. So i can't add/remove host."), + next => 0, + end => 1, + }, summaryslave => { name => N('Ok Now building your DNS slave configuration') . "\n\n" . N('with this configuration:'), data => [ - { label => N('Ip of master DNS server'), fixed_val => \$o->{var}{IPMASTER} }, + { label => N('Ip of master DNS server:'), fixed_val => \$o->{var}{IPMASTER} }, ], post => \&do_it_slave, next => 'end', @@ -222,10 +232,10 @@ $o->{pages} = { summary => { name => N('Ok Now building your DNS configuration') . "\n\n" . N('with this configuration:'), data => [ - { label => N('Server Hostname'), fixed_val => \$o->{var}{SHORTHOSTNAME} }, - { label => N('Domainname'), fixed_val => \$o->{var}{DOMAINNAME} }, - { label => N('IP forwarders'), fixed_val => \$o->{var}{IPOFFORWARDER} }, - { label => N('add search domain'), fixed_val => \$o->{var}{ADDSEARCH} }, + { label => N('Server Hostname:'), fixed_val => \$o->{var}{SHORTHOSTNAME} }, + { label => N('Domainname:'), fixed_val => \$o->{var}{DOMAINNAME} }, + { label => N('IP forwarders:'), fixed_val => \$o->{var}{IPOFFORWARDER} }, + { label => N('add search domain:'), fixed_val => \$o->{var}{ADDSEARCH} }, ], post => \&do_it_master, next => 'end', @@ -255,6 +265,16 @@ sub check_dhcp { $wiz->{net}->is_dhcp() and return 'dhcp_warning'; } +sub test_srv { + my $dir = "/var/named/zone"; + -d $dir or return 'error_nosrv'; +} + +sub test_master { + my $ft = "/var/named/master_srv"; + -f $ft or return 'error_notmaster'; +} + sub interface_to_ip { my ($interface) = @_; my ($ip) = `/sbin/ip addr show dev $interface` =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/m; @@ -672,12 +692,14 @@ 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 ...")); + my $ft = "/var/named/master_srv"; + system("touch $ft"); do_it(); crea_iprev($IPSERVER, $DOMAINNAME); crea_ipnorm($IPSERVER, $DOMAINNAME); crea_named_master($IPSERVER, $DOMAINNAME); end_it(); -undef $w; + undef $w; } sub do_it_slave { @@ -709,6 +731,8 @@ sub get_shortname { sub do_it_add { return if $::testing; + test_master(); + test_srv(); my $iprev = get_spe_ip('iprev', $IPSERVER); my $ipend = get_spe_ip('ipend', $o->{var}{CLIENTIP}); my $SNAME= get_shortname($o->{var}{CLIENTNAME}); @@ -728,6 +752,8 @@ sub do_it_add { sub do_it_remove { return if $::testing; + test_master(); + test_srv(); my $iprev = get_spe_ip('iprev', $IPSERVER); my $NAME= $o->{var}{CLIENTNAME}; substInFile { |