/[pxelator]/lib/PXElator/dhcpd.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/dhcpd.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 153 by dpavlin, Wed Aug 5 23:22:17 2009 UTC revision 156 by dpavlin, Thu Aug 6 15:15:53 2009 UTC
# Line 40  my $addr = $server::ip_from; Line 40  my $addr = $server::ip_from;
40  sub client_ip {  sub client_ip {
41          my ( $mac ) = @_;          my ( $mac ) = @_;
42    
43          my $conf = "$server::base_dir/conf/$server::ip";          my $conf = $server::conf;
44          mkdir $conf unless -e $conf;          mkdir $conf unless -e $conf;
45    
46          if ( -e "$conf/mac/$mac" ) {          if ( -e "$conf/mac/$mac" ) {
# Line 54  sub client_ip { Line 54  sub client_ip {
54          my $prefix = $server::ip;          my $prefix = $server::ip;
55          $prefix =~ s{\.\d+$}{.};          $prefix =~ s{\.\d+$}{.};
56          my $ip = $prefix . $addr;          my $ip = $prefix . $addr;
57    
58          while ( -e "$conf/ip/$ip" || $p->ping( $ip ) ) {          while ( -e "$conf/ip/$ip" || $p->ping( $ip ) ) {
59                  $ip = $prefix . $addr++;                  $ip = $prefix . $addr++;
60                  die "all addresses allocated!" if $addr == $server::ip_to;                  die "all addresses allocated!" if $addr == $server::ip_to;
# Line 61  sub client_ip { Line 62  sub client_ip {
62    
63          write_file "$conf/mac/$mac", $ip;          write_file "$conf/mac/$mac", $ip;
64    
65          if ( -l "$conf/ip/$ip" && readlink "$conf/ip/$ip" ne "$conf/mac/$mac" ) {          my $ip_path = "$conf/ip/$ip";
66                  unlink     "$conf/ip/$ip";          mkdir $ip_path unless -e $ip_path;
67                  warn "$mac IP changed from ", readlink "$conf/ip/$ip", " to $ip";  
68            if ( -l "$ip_path/mac" && readlink "$ip_path/mac" ne "$conf/mac/$mac" ) {
69                    warn "$mac IP changed from ", readlink "$ip_path/mac", " to $ip";
70                    unlink "$ip_path/mac";
71          };          };
72          symlink    "$conf/mac/$mac", "$conf/ip/$ip";          symlink "$conf/mac/$mac", "$ip_path/mac";
73    
74          print "$mac NEW $ip\n";          print "$mac NEW $ip\n";
75    

Legend:
Removed from v.153  
changed lines
  Added in v.156

  ViewVC Help
Powered by ViewVC 1.1.26