--- lib/PXElator/dhcpd.pm 2009/08/06 21:31:10 168 +++ lib/PXElator/dhcpd.pm 2009/08/10 17:30:01 194 @@ -42,16 +42,17 @@ my $conf = $server::conf; mkdir $conf unless -e $conf; - if ( -e "$conf/mac/$mac" ) { - my $ip = read_file "$conf/mac/$mac"; + my $ip; + + if ( $ip = client::ip_from_mac( $mac ) ) { print "RENEW $mac $ip\n"; return $ip; + } else { + $ip = client::next_ip; + print "NEW $mac $ip\n"; + symlink "$conf/ip/$ip", "$conf/mac/$mac"; } - my $ip = client::next_ip; - - write_file "$conf/mac/$mac", $ip; - my $ip_path = "$conf/ip/$ip"; mkdir $ip_path unless -e $ip_path; @@ -59,9 +60,8 @@ warn "$mac IP changed from ", readlink "$ip_path/mac", " to $ip"; unlink "$ip_path/mac"; }; - symlink "$conf/mac/$mac", "$ip_path/mac"; - print "$mac NEW $ip\n"; + symlink "$conf/mac/$mac", "$ip_path/mac"; return $ip; }