--- lib/PXElator/server.pm 2009/09/08 16:54:35 393 +++ lib/PXElator/server.pm 2009/09/09 10:48:59 410 @@ -5,16 +5,19 @@ our $base_dir = '/srv/pxelator'; -tie our $ip, 'server::tie', 'ip' => '172.16.10.1'; -tie our $netmask, 'server::tie', 'natmask' => '255.255.255.0'; -tie our $bcast, 'server::tie', 'bcast' => '172.16.10.254'; -tie our $ip_from, 'server::tie', 'ip_from' => 10; -tie our $ip_to, 'server::tie', 'ip_to' => 100; -tie our $domain, 'server::tie', 'domain' => 'pxelator.lan'; +use ties; + +tie our $ip, 'ties', 'server_ip' => '172.16.10.1'; +tie our $netmask, 'ties', 'natmask' => '255.255.255.0'; +tie our $bcast, 'ties', 'bcast' => '172.16.10.254'; +tie our $ip_from, 'ties', 'ip_from' => 10; +tie our $ip_to, 'ties', 'ip_to' => 100; +tie our $domain, 'ties', 'domain' => 'pxelator.lan'; +tie our $new_clients, 'ties', 'new_clients' => $ip_to - $ip_from; warn "DEV $ip $bcast $netmask"; -our $conf = "$base_dir/conf/$ip"; +our $conf = "$base_dir/conf"; mkdir $conf unless -e $conf; sub conf { @@ -55,45 +58,4 @@ warn "loaded"; - -package server::tie; - -use File::Slurp; -use Data::Dump qw/dump/; - -use server; - -sub TIESCALAR { - warn dump @_; - my ($class,$name,$default) = @_; - - my $path = $server::base_dir; - if ( $name eq 'ip' ) { - $path .= '/conf/' . $ip; - } else { - $path .= '/conf/' . $server::ip; - } - - my $o = { - path => "$path/$name", - }; - write_file $o->{path}, $default unless -f $o->{path}; - -warn "TIESCALAR $name ", $o->{path}, " [$default]"; - - bless \$o,$class; -} - -sub STORE { - warn dump @_; - my ( $self, $value ) = @_; - write_file $$self->{path}, $value; -} - -sub FETCH { - warn dump @_; - my $self = shift; - read_file $$self->{path}; -} - -3; +1;