--- lib/PXElator/dhcpd.pm 2009/08/06 21:31:10 168 +++ lib/PXElator/dhcpd.pm 2009/08/07 14:08:21 177 @@ -42,16 +42,18 @@ my $conf = $server::conf; mkdir $conf unless -e $conf; + my $ip; + if ( -e "$conf/mac/$mac" ) { - my $ip = read_file "$conf/mac/$mac"; + $ip = read_file "$conf/mac/$mac"; print "RENEW $mac $ip\n"; return $ip; + } else { + $ip = client::next_ip; + print "NEW $mac $ip\n"; + write_file "$conf/mac/$mac", $ip; } - 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 +61,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; }