/[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 270 by dpavlin, Wed Aug 19 18:10:37 2009 UTC revision 527 by dpavlin, Fri Sep 17 17:18:30 2010 UTC
# Line 3  package server; Line 3  package server;
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6    use Data::Dump qw(dump);
7    use YAML qw();
8    
9  our $ip      = '172.16.10.1';  our $base_dir = '/srv/pxelator';
10  our $netmask = '255.255.255.0';  
11  our $bcast   = '172.16.10.255';  use ties;
12    
13    tie our $ip,      'ties', 'server_ip' => '172.16.10.1';
14    tie our $netmask, 'ties', 'netmask'   => '255.255.255.0';
15    tie our $bcast,   'ties', 'bcast'     => '172.16.10.254';
16    tie our $ip_from, 'ties', 'ip_from'   => 10;
17    tie our $ip_to,   'ties', 'ip_to'     => 100;
18    tie our $domain,  'ties', 'domain'    => 'pxelator.lan';
19    tie our $new_clients, 'ties', 'new_clients' => $ip_to - $ip_from;
20    
21  if ( my $dev = $ENV{DEV} ) {  if ( my $dev = $ENV{DEV} ) {
22          my $ifconfig = `ifconfig $dev`;          my $ifconfig = `ifconfig $dev`;
23          ( $ip, $bcast, $netmask ) = ( $1, $2, $3 ) if $ifconfig =~ m{inet addr:(\S+)\s+Bcast:(\S+)\s+Mask:(\S+)}s;          die "can't ifconfig $dev" unless $ifconfig;
24          warn "DEV $dev $ip $bcast $netmask";          $ip      = $1 if $ifconfig =~ m/inet addr:(\S+)/s;
25            $netmask = $1 if $ifconfig =~ m/Mask:(\S+)/s;
26            $bcast   = $1 if $ifconfig =~ m/Bcast:(\S)/s;
27  }  }
28    
29  our ( $ip_from, $ip_to ) = ( 10, 100 );  warn "DEV $ip $bcast $netmask";
   
 our $domain_name = 'pxelator.lan';  
30    
31  our $base_dir = '/srv/pxelator';  our $conf = "$base_dir/conf";
   
 our $conf = "$base_dir/conf/$ip";  
32  mkdir $conf unless -e $conf;  mkdir $conf unless -e $conf;
33    
34    sub conf {
35            warn "## conf $conf";
36            $conf;
37    }
38    
39  use Module::Refresh qw//;  use Module::Refresh qw//;
40  sub refresh {  sub refresh {
41          Module::Refresh->refresh;          Module::Refresh->refresh;
# Line 54  sub conf_default { shared($_[0]) || $_[1 Line 67  sub conf_default { shared($_[0]) || $_[1
67    
68  sub debug { shared('debug', @_) || 0 }  sub debug { shared('debug', @_) || 0 }
69    
70    sub as_hash_for {
71            my $ip = shift;
72    
73            my $server;
74            map { $server->{ $_ } = eval '$server::' . $_ } ( 'ip', 'netmask', 'bcast', 'domain', 'ip_from', 'ip_to', 'new_clients' );
75    
76            my $server_path = "$server::conf/ip/$ip/server.yaml";
77            $server =  YAML::LoadFile $server_path if -e $server_path;
78    
79            return $server;
80    }
81    
82  warn "loaded";  warn "loaded";
83    
84  1;  1;

Legend:
Removed from v.270  
changed lines
  Added in v.527

  ViewVC Help
Powered by ViewVC 1.1.26