/[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 179 by dpavlin, Sun Aug 9 16:37:46 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    
25    use Module::Refresh qw//;
26    sub refresh { Module::Refresh->refresh };
27    
28    
29    mkdir $_ foreach grep { ! -d $_ } map { "$conf/$_" } ( 'ip', 'mac' );
30    
31    use File::Slurp;
32    sub shared {
33            my ($name, $value) = @_;
34    
35            my $path ="$conf/$name";
36            if ( defined $value ) {
37                    write_file $path, $value;
38                    warn "update $path = $value";
39            } else {
40                    $value = read_file $path if -e $path;
41            }
42            return $value;
43    }
44    
45  our $debug;  sub debug { shared('debug', @_) || 0 }
 sub debug { $debug = config::shared('debug', @_) || 0 }  
46    
47  warn "loaded";  warn "loaded";
48    

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

  ViewVC Help
Powered by ViewVC 1.1.26