/[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 134 by dpavlin, Tue Aug 4 13:18:36 2009 UTC revision 198 by dpavlin, Tue Aug 11 12:39:05 2009 UTC
# Line 3  package server; Line 3  package server;
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
 use Module::Refresh qw//;  
 sub x_refresh { Module::Refresh->refresh };  
6    
7  our $ip      = '172.16.10.1';  our $ip      = '172.16.10.1';
8  our $netmask = '255.255.255.0';  our $netmask = '255.255.255.0';
9    our $bcast   = '172.16.10.255';
10    
11    if ( my $dev = $ENV{DEV} ) {
12            my $ifconfig = `ifconfig $dev`;
13            ( $ip, $bcast, $netmask ) = ( $1, $2, $3 ) if $ifconfig =~ m{inet addr:(\S+)\s+Bcast:(\S+)\s+Mask:(\S+)}s;
14            warn "DEV $dev $ip $bcast $netmask";
15    }
16    
17  our ( $ip_from, $ip_to ) = ( 10, 100 );  our ( $ip_from, $ip_to ) = ( 10, 100 );
18    
19    our $domain_name = 'pxelator.lan';
20    
21  our $base_dir = '/srv/pxelator';  our $base_dir = '/srv/pxelator';
22    
23  use config;  our $conf = "$base_dir/conf/$ip";
24    mkdir $conf unless -e $conf;
25    
26    use Module::Refresh qw//;
27    sub refresh { Module::Refresh->refresh };
28    
29    
30    mkdir $_ foreach grep { ! -d $_ } map { "$conf/$_" } ( 'ip', 'mac' );
31    
32    use File::Slurp;
33    sub shared {
34            my ($name, $value) = @_;
35    
36            my $path ="$conf/$name";
37            if ( defined $value ) {
38                    write_file $path, $value;
39                    warn "update $path = $value";
40            } else {
41                    $value = read_file $path if -e $path;
42            }
43            return $value;
44    }
45    
46  our $debug;  sub debug { shared('debug', @_) || 0 }
 sub debug { $debug = config::shared('debug', @_) || 0 }  
47    
48  warn "loaded";  warn "loaded";
49    

Legend:
Removed from v.134  
changed lines
  Added in v.198

  ViewVC Help
Powered by ViewVC 1.1.26