/[pxelator]/lib/PXElator/server.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/server.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 45 by dpavlin, Wed Jul 29 22:04:58 2009 UTC revision 410 by dpavlin, Wed Sep 9 10:48:59 2009 UTC
# Line 1  Line 1 
1  package server;  package server;
2    
3  our $ip = '172.16.10.1';  use warnings;
4    use strict;
5    
6  our ( $ip_from, $ip_to ) = ( 10, 100 );  our $base_dir = '/srv/pxelator';
7    
8    use ties;
9    
10    tie our $ip,      'ties', 'server_ip' => '172.16.10.1';
11    tie our $netmask, 'ties', 'natmask'   => '255.255.255.0';
12    tie our $bcast,   'ties', 'bcast'     => '172.16.10.254';
13    tie our $ip_from, 'ties', 'ip_from'   => 10;
14    tie our $ip_to,   'ties', 'ip_to'     => 100;
15    tie our $domain,  'ties', 'domain'    => 'pxelator.lan';
16    tie our $new_clients, 'ties', 'new_clients' => $ip_to - $ip_from;
17    
18    warn "DEV $ip $bcast $netmask";
19    
20    our $conf = "$base_dir/conf";
21    mkdir $conf unless -e $conf;
22    
23    sub conf {
24            warn "## conf $conf";
25            $conf;
26    }
27    
28    use Module::Refresh qw//;
29    sub refresh {
30            Module::Refresh->refresh;
31            my $from = (caller(1))[3];
32            $from =~ s{^(\w+)::.+$}{$1};
33            my $eval = '$' . $from . '::debug = server::debug();';
34            warn "refresh $eval\n";
35            eval $eval;
36            warn $@ if $@;
37    };
38    
39    mkdir $_ foreach grep { ! -d $_ } map { "$conf/$_" } ( 'ip', 'mac' );
40    
41    use File::Slurp;
42    sub shared {
43            my ($name, $value) = @_;
44    
45            my $path ="$conf/$name";
46            if ( defined $value ) {
47                    write_file $path, $value;
48                    warn "update $path = $value";
49            } else {
50                    $value = read_file $path if -e $path;
51            }
52            return $value;
53    }
54    
55    sub conf_default { shared($_[0]) || $_[1] }
56    
57    sub debug { shared('debug', @_) || 0 }
58    
59  warn "loaded";  warn "loaded";
60    
61    1;

Legend:
Removed from v.45  
changed lines
  Added in v.410

  ViewVC Help
Powered by ViewVC 1.1.26