--- lib/PXElator/server.pm 2009/08/06 18:09:17 160 +++ lib/PXElator/server.pm 2009/09/09 19:57:07 416 @@ -3,22 +3,38 @@ use warnings; use strict; - -our $ip = '172.16.10.1'; -our $netmask = '255.255.255.0'; -our $bcast = '172.16.10.255'; - -our ( $ip_from, $ip_to ) = ( 10, 100 ); - -our $domain_name = 'pxelator.lan'; - our $base_dir = '/srv/pxelator'; -our $conf = "$base_dir/conf/$ip"; +use ties; -use Module::Refresh qw//; -sub refresh { Module::Refresh->refresh }; +tie our $ip, 'ties', 'server_ip' => '172.16.10.1'; +tie our $netmask, 'ties', 'netmask' => '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"; +mkdir $conf unless -e $conf; + +sub conf { + warn "## conf $conf"; + $conf; +} +use Module::Refresh qw//; +sub refresh { + Module::Refresh->refresh; + my $from = (caller(1))[3]; + $from =~ s{^(\w+)::.+$}{$1}; + my $eval = '$' . $from . '::debug = server::debug();'; + warn "refresh $eval\n"; + eval $eval; + warn $@ if $@; +}; mkdir $_ foreach grep { ! -d $_ } map { "$conf/$_" } ( 'ip', 'mac' ); @@ -36,6 +52,8 @@ return $value; } +sub conf_default { shared($_[0]) || $_[1] } + sub debug { shared('debug', @_) || 0 } warn "loaded";