6 our $base_dir = '/srv/pxelator';
8 tie our $ip, 'server::tie', 'server_ip' => '172.16.10.1';
9 tie our $netmask, 'server::tie', 'natmask' => '255.255.255.0';
10 tie our $bcast, 'server::tie', 'bcast' => '172.16.10.254';
11 tie our $ip_from, 'server::tie', 'ip_from' => 10;
12 tie our $ip_to, 'server::tie', 'ip_to' => 100;
13 tie our $domain, 'server::tie', 'domain' => 'pxelator.lan';
14 tie our $new_clients, 'server::tie', 'new_clients' => $ip_to - $ip_from;
16 warn "DEV $ip $bcast $netmask";
18 our $conf = "$base_dir/conf";
19 mkdir $conf unless -e $conf;
26 use Module::Refresh qw//;
28 Module::Refresh->refresh;
29 my $from = (caller(1))[3];
30 $from =~ s{^(\w+)::.+$}{$1};
31 my $eval = '$' . $from . '::debug = server::debug();';
32 warn "refresh $eval\n";
37 mkdir $_ foreach grep { ! -d $_ } map { "$conf/$_" } ( 'ip', 'mac' );
41 my ($name, $value) = @_;
43 my $path ="$conf/$name";
44 if ( defined $value ) {
45 write_file $path, $value;
46 warn "update $path = $value";
48 $value = read_file $path if -e $path;
53 sub conf_default { shared($_[0]) || $_[1] }
55 sub debug { shared('debug', @_) || 0 }
63 use Data::Dump qw/dump/;
69 my ($class,$name,$default) = @_;
71 my $path = $server::base_dir . '/conf/' . $name;
76 write_file $o->{path}, $default unless -f $o->{path};
78 warn "TIESCALAR $name ", $o->{path}, " [$default]";
85 my ( $self, $value ) = @_;
86 write_file $$self->{path}, $value;
92 read_file $$self->{path};