6 |
|
|
7 |
our $ip = '172.16.10.1'; |
our $ip = '172.16.10.1'; |
8 |
our $netmask = '255.255.255.0'; |
our $netmask = '255.255.255.0'; |
9 |
|
our $bcast = '172.16.10.255'; |
10 |
|
|
11 |
our ( $ip_from, $ip_to ) = ( 10, 100 ); |
our ( $ip_from, $ip_to ) = ( 10, 100 ); |
12 |
|
|
13 |
|
our $domain_name = 'pxelator.lan'; |
14 |
|
|
15 |
our $base_dir = '/srv/pxelator'; |
our $base_dir = '/srv/pxelator'; |
16 |
|
|
17 |
|
our $conf = "$base_dir/conf/$ip"; |
18 |
|
|
19 |
use Module::Refresh qw//; |
use Module::Refresh qw//; |
20 |
sub refresh { Module::Refresh->refresh }; |
sub refresh { Module::Refresh->refresh }; |
21 |
|
|
22 |
|
|
23 |
|
mkdir $_ foreach grep { ! -d $_ } map { "$conf/$_" } ( 'ip', 'mac' ); |
24 |
|
|
25 |
use File::Slurp; |
use File::Slurp; |
26 |
sub shared { |
sub shared { |
27 |
my ($name, $value) = @_; |
my ($name, $value) = @_; |
28 |
|
|
29 |
my $path ="$base_dir/conf/$server::ip/$name"; |
my $path ="$conf/$name"; |
30 |
if ( defined $value ) { |
if ( defined $value ) { |
31 |
write_file $path, $value; |
write_file $path, $value; |
32 |
|
warn "update $path = $value"; |
33 |
} else { |
} else { |
34 |
$value = read_file $path if -e $path; |
$value = read_file $path if -e $path; |
35 |
} |
} |