diff options
Diffstat (limited to 'dhcp_wizard/Dhcp.pm')
-rwxr-xr-x | dhcp_wizard/Dhcp.pm | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/dhcp_wizard/Dhcp.pm b/dhcp_wizard/Dhcp.pm index 3bb73ef1..60f293a7 100755 --- a/dhcp_wizard/Dhcp.pm +++ b/dhcp_wizard/Dhcp.pm @@ -31,16 +31,16 @@ use MDK::Wizard::Wizcommon; my $wiz = new MDK::Wizard::Wizcommon; my $wiz_ip_server = $wiz->{net}->itf_get("IPADDR"); -my $d = "$4" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; +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})/; my $o = { - name => N('DHCP Wizard'), + name => N("DHCP Wizard"), var => { ip1 => '', ip2 => '', wiz_authoritative => 0, - einterface => $wiz->{net}->default_itf() + einterface => $wiz->{net}->default_itf }, needed_rpm => [ 'dhcp-server' ], defaultimage => "$ENV{__WIZ_HOME__}dhcp_wizard/images/DHCP.png" @@ -48,28 +48,28 @@ my $o = { $o->{pages} = { welcome => { - name => N('DHCP Wizard') . "\n\n\n" . N('DHCP is a service that automatically assigns networking addresses to your workstations.') . "\n\n\n" . N('This wizard will help you configuring the DHCP services of your server.'), + name => N("DHCP Wizard") . "\n\n\n" . N("DHCP is a service that automatically assigns networking addresses to your workstations.") . "\n\n\n" . N("This wizard will help you configuring the DHCP services of your server."), post => sub { $wiz->check_dhcp }, no_back => 1, next => 'ip_range' }, ip_range => { - name => N('Range of addresses used by dhcp') . "\n\n\n" . N('Select the range of addresses assigned to the workstations by the DHCP service; unless you have special needs, you can safely accept the proposed values.'), + name => N("Range of addresses used by dhcp") . "\n\n\n" . N("Select the range of addresses assigned to the workstations by the DHCP service; unless you have special needs, you can safely accept the proposed values."), pre => sub { $o->{var}{ip1} ||= compute_range(); $o->{var}{ip2} ||= compute_range2() }, post => \&check, data => [ - { label => N('Lowest IP Address:'), val => \$o->{var}{ip1} }, - { label => N('Highest IP Address:'), val => \$o->{var}{ip2} }, + { 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'), + name => N("Interface the dhcp server must listen to"), pre => sub { - $o->{var}{interface} ||= $wiz->{net}->default_itf() + $o->{var}{interface} ||= $wiz->{net}->default_itf }, data => [ { list => [ keys %{$wiz->{net}{itf}} ], val => \$o->{var}{interface} }, @@ -77,37 +77,37 @@ $o->{pages} = { next => 'summary' }, dhcp_warning => { - name => N('Warning') . "\n\n" . N('You are in dhcp, server may not work with your configuration.'), + name => N("Warning") . "\n\n" . N("You are in dhcp, server may not work with your configuration."), ignore => 1, next => 'ip_range' }, ip_range_error => { - name => N('Error') . "\n\n" . N('The IP range specified is not correct.'), + name => N("Error") . "\n\n" . N("The IP range specified is not correct."), ignore => 1, next => 'ip_range' }, ip_range_warning => { - name => N('Warning') . "\n\n" . N('The IP range specified is not in server address range.'), + name => N("Warning") . "\n\n" . N("The IP range specified is not in server address range."), ignore => 1, next => 'summary' }, server_in_range => { - name => N('Error') . "\n\n" . N('The IP of the server must not be in range.'), + name => N("Error") . "\n\n" . N("The IP of the server must not be in range."), ignore => 1, next => 'ip_range' }, summary => { - name => N('Configuring the DHCP Server') . "\n\n" . N('The wizard collected the following parameters needed to configure your DHCP service:'), + 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 => N('Highest IP Address:'), fixed_val => \$o->{var}{ip2} }, - { label => N('Interface:'), fixed_val => \$o->{var}{interface} }, + { label => N("Lowest IP Address:"), fixed_val => \$o->{var}{ip1} }, + { label => N("Highest IP Address:"), fixed_val => \$o->{var}{ip2} }, + { label => N("Interface:"), fixed_val => \$o->{var}{interface} }, ], post => \&do_it, next => 'end' }, end => { - name => N('Congratulationss') . "\n\n" . N('The wizard successfully configured the DHCP services of your server.'), + name => N("Congratulationss") . "\n\n" . N("The wizard successfully configured the DHCP services of your server."), end => 1, next => 0 }, @@ -117,7 +117,7 @@ sub compute_range { my $n; if ($d <= 64) { $n = "65" } elsif ($d <= 128) { $n = "129" } - else { $n = "1"} + else { $n = "1" } "$s.$n"; } @@ -125,28 +125,28 @@ sub compute_range2 { my $n; if ($d <= 128) { $n = "254" } elsif ($d > 192) { $n = "192" } - else { $n = "128"} + else { $n = "128" } "$s.$n"; } sub check { - my $check_ip = sub { return 0 if ($_[0] < 0 || $_[0] > 255); 1 }; + my $check_ip = sub { return $_[0] < 0 || $_[0] > 255 ? 0 : 1 }; my $r1_trunc = "$1.$2.$3" if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; foreach ($1, $2, $3, $4) { $check_ip->($_) or return 'ip_range_error' } my $r2_trunc = "$1.$2.$3" if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; foreach ($1, $2, $3, $4) { $check_ip->($_) or return 'ip_range_error' } - my $d1 = "$4" if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - my $d2 = "$4" if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + my $d1 = $4 if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + my $d2 = $4 if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; my $s_trunc = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - my $ds = "$4" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - if (!$r1_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 1"); return 'ip_range_error'} - if (!$r2_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 2"); return 'ip_range_error'} + my $ds = $4 if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + if (!$r1_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 1"); return 'ip_range_error' } + if (!$r2_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 2"); return 'ip_range_error' } if ($r1_trunc ne $s_trunc || $r2_trunc ne $s_trunc) { standalone::explanations("DHCP wizard : range not in network"); return 'ip_range_warning'; } - 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'} + 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 } @@ -179,7 +179,7 @@ sub do_it { my $file = "/etc/sysconfig/dhcpd"; -f $file and MDK::Common::cp_af($file, $file.".orig"); standalone::explanations("now patching etc/sysconfig/dhcpd"); - if (!`grep INTERFACES $file`){ + if (!`grep INTERFACES $file`) { 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: $!"; @@ -208,7 +208,7 @@ sub do_it { s|__dname__|$wiz_domain_name|g; s|__gateway__|$wiz_gateway|g; $_; - } cat_ ("__WIZ_HOME__/dhcp_wizard/scripts/dhcpd.conf.default")); + } cat_("__WIZ_HOME__/dhcp_wizard/scripts/dhcpd.conf.default")); standalone::explanations("$file: hname = $wiz_host_name, net = $wiz_ip_net, ip = $wiz_ip_server, mask = $wiz_ip_netmask, rng1 = $wiz_ip_range1, rng2 = $wiz_ip_range2, dname = $wiz_domain_name"); MDK::Common::touch("/var/dhcpd/dhcpd.leases"); @@ -220,10 +220,10 @@ mask = $wiz_ip_netmask, rng1 = $wiz_ip_range1, rng2 = $wiz_ip_range2, dname = $w $mdk{interfaces} = $wiz_device; standalone::explanations("$file: lease_file = $mdk{lease_file}, interfaces = $mdk{interfaces}"); MDK::Wizard::Varspaceval->commit($file, \%mdk); - !$o-{var}{wiz_authoritative} and output($file, map { - s|^\s*not\s*authoritative.*|\#$&|i; + !$o->{var}{wiz_authoritative} and output($file, map { + s|^\s*not\s*authoritative.*|#$&|i; $_ - } cat_ ("/etc/dhcpd.conf")); + } cat_("/etc/dhcpd.conf")); } if (services::is_service_running('dhcpd')) { services::restart('dhcpd') |