42 |
my $conf = $server::conf; |
my $conf = $server::conf; |
43 |
mkdir $conf unless -e $conf; |
mkdir $conf unless -e $conf; |
44 |
|
|
45 |
if ( -e "$conf/mac/$mac" ) { |
my $ip; |
46 |
my $ip = read_file "$conf/mac/$mac"; |
|
47 |
|
if ( $ip = client::ip_from_mac( $mac ) ) { |
48 |
print "RENEW $mac $ip\n"; |
print "RENEW $mac $ip\n"; |
49 |
return $ip; |
return $ip; |
50 |
|
} else { |
51 |
|
$ip = client::next_ip( $mac ); |
52 |
|
print "NEW $mac $ip\n"; |
53 |
} |
} |
54 |
|
|
|
my $ip = client::next_ip; |
|
|
|
|
|
write_file "$conf/mac/$mac", $ip; |
|
|
|
|
|
my $ip_path = "$conf/ip/$ip"; |
|
|
mkdir $ip_path unless -e $ip_path; |
|
|
|
|
|
if ( -l "$ip_path/mac" && readlink "$ip_path/mac" ne "$conf/mac/$mac" ) { |
|
|
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"; |
|
|
|
|
55 |
return $ip; |
return $ip; |
56 |
} |
} |
57 |
|
|