/[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 416 by dpavlin, Wed Sep 9 19:57:07 2009 UTC revision 530 by dpavlin, Fri Sep 17 18:20:36 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 $base_dir = '/srv/pxelator';  our $base_dir = '/srv/pxelator';
10    
11  use ties;  use ties;
# Line 15  tie our $ip_to,   'ties', 'ip_to'     => Line 18  tie our $ip_to,   'ties', 'ip_to'     =>
18  tie our $domain,  'ties', 'domain'    => 'pxelator.lan';  tie our $domain,  'ties', 'domain'    => 'pxelator.lan';
19  tie our $new_clients, 'ties', 'new_clients' => $ip_to - $ip_from;  tie our $new_clients, 'ties', 'new_clients' => $ip_to - $ip_from;
20    
21    if ( my $dev = $ENV{DEV} ) {
22            my $ifconfig = `ifconfig $dev`;
23            die "can't ifconfig $dev" unless $ifconfig;
24            die "device $dev not up: ifconfig $dev\n$ifconfig" unless $ifconfig =~ m/UP/;
25            $ip      = $1 if $ifconfig =~ m/inet addr:(\S+)/s;
26            $netmask = $1 if $ifconfig =~ m/Mask:(\S+)/s;
27            $bcast   = $1 if $ifconfig =~ m/Bcast:(\S+)/s;
28    }
29    
30  warn "DEV $ip $bcast $netmask";  warn "DEV $ip $bcast $netmask";
31    
32  our $conf = "$base_dir/conf";  our $conf = "$base_dir/conf";
# Line 56  sub conf_default { shared($_[0]) || $_[1 Line 68  sub conf_default { shared($_[0]) || $_[1
68    
69  sub debug { shared('debug', @_) || 0 }  sub debug { shared('debug', @_) || 0 }
70    
71    sub as_hash_for {
72            my $ip = shift;
73    
74            my $server;
75            map { $server->{ $_ } = eval '$server::' . $_ } ( 'ip', 'netmask', 'bcast', 'domain', 'ip_from', 'ip_to', 'new_clients' );
76    
77            my $server_path = "$server::conf/ip/$ip/server.yaml";
78            $server =  YAML::LoadFile $server_path if -e $server_path;
79    
80            return $server;
81    }
82    
83  warn "loaded";  warn "loaded";
84    
85  1;  1;

Legend:
Removed from v.416  
changed lines
  Added in v.530

  ViewVC Help
Powered by ViewVC 1.1.26