42 |
my $conf = $server::conf; |
my $conf = $server::conf; |
43 |
mkdir $conf unless -e $conf; |
mkdir $conf unless -e $conf; |
44 |
|
|
45 |
|
my $ip; |
46 |
|
|
47 |
if ( -e "$conf/mac/$mac" ) { |
if ( -e "$conf/mac/$mac" ) { |
48 |
my $ip = read_file "$conf/mac/$mac"; |
$ip = read_file "$conf/mac/$mac"; |
49 |
print "RENEW $mac $ip\n"; |
print "RENEW $mac $ip\n"; |
50 |
return $ip; |
return $ip; |
51 |
|
} else { |
52 |
|
$ip = client::next_ip; |
53 |
|
print "NEW $mac $ip\n"; |
54 |
|
write_file "$conf/mac/$mac", $ip; |
55 |
} |
} |
56 |
|
|
|
my $ip = client::next_ip; |
|
|
|
|
|
write_file "$conf/mac/$mac", $ip; |
|
|
|
|
57 |
my $ip_path = "$conf/ip/$ip"; |
my $ip_path = "$conf/ip/$ip"; |
58 |
mkdir $ip_path unless -e $ip_path; |
mkdir $ip_path unless -e $ip_path; |
59 |
|
|
61 |
warn "$mac IP changed from ", readlink "$ip_path/mac", " to $ip"; |
warn "$mac IP changed from ", readlink "$ip_path/mac", " to $ip"; |
62 |
unlink "$ip_path/mac"; |
unlink "$ip_path/mac"; |
63 |
}; |
}; |
|
symlink "$conf/mac/$mac", "$ip_path/mac"; |
|
64 |
|
|
65 |
print "$mac NEW $ip\n"; |
symlink "$conf/mac/$mac", "$ip_path/mac"; |
66 |
|
|
67 |
return $ip; |
return $ip; |
68 |
} |
} |