/[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 153 by dpavlin, Wed Aug 5 23:22:17 2009 UTC revision 410 by dpavlin, Wed Sep 9 10:48:59 2009 UTC
# Line 3  package server; Line 3  package server;
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6    our $base_dir = '/srv/pxelator';
7    
8  our $ip      = '172.16.10.1';  use ties;
 our $netmask = '255.255.255.0';  
   
 our ( $ip_from, $ip_to ) = ( 10, 100 );  
   
 our $domain_name = 'pxelator.lan';  
9    
10  our $base_dir = '/srv/pxelator';  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//;  use Module::Refresh qw//;
29  sub refresh { Module::Refresh->refresh };  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 { ! -e $_ } map { "$base_dir/conf/$server::ip/$_" } ( 'ip', 'mac', 'hostname', 'deploy' );  mkdir $_ foreach grep { ! -d $_ } map { "$conf/$_" } ( 'ip', 'mac' );
40    
41  use File::Slurp;  use File::Slurp;
42  sub shared {  sub shared {
43          my ($name, $value) = @_;          my ($name, $value) = @_;
44    
45          my $path ="$base_dir/conf/$server::ip/$name";          my $path ="$conf/$name";
46          if ( defined $value ) {          if ( defined $value ) {
47                  write_file $path, $value;                  write_file $path, $value;
48                  warn "update $path = $value";                  warn "update $path = $value";
# Line 32  sub shared { Line 52  sub shared {
52          return $value;          return $value;
53  }  }
54    
55    sub conf_default { shared($_[0]) || $_[1] }
56    
57  sub debug { shared('debug', @_) || 0 }  sub debug { shared('debug', @_) || 0 }
58    
59  warn "loaded";  warn "loaded";

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

  ViewVC Help
Powered by ViewVC 1.1.26