/[pxelator]/lib/PXElator/client.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

Contents of /lib/PXElator/client.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 165 - (show annotations)
Thu Aug 6 18:51:57 2009 UTC (14 years, 8 months ago) by dpavlin
File size: 934 byte(s)
display client mac addresses
1 package client;
2
3 use warnings;
4 use strict;
5 use autodie;
6
7 use server;
8 use File::Slurp;
9
10 sub conf {
11 my $ip = shift;
12 my $name = shift;
13 my ( $default, $value );
14 if ( $#_ == 0 ) {
15 $value = shift;
16 } elsif ( $#_ == 1 && $_[0] eq 'default' ) {
17 $default = $_[1]
18 }
19
20 my $path ="$server::conf/ip/$ip";
21 mkdir $path unless -d $path;
22 $path .= '/' . $name;
23
24 if ( defined $value ) {
25 write_file $path, $value;
26 warn "update $path = $value";
27 } elsif ( ! -e $path && defined $default ) {
28 write_file $path, $default;
29 warn "default $path = $default";
30 $value = $default;
31 } elsif ( -e $path ) {
32 if ( -l $path ) {
33 $value = readlink $path;
34 $value =~ s{.*/([^/]+)$}{$1};
35 } else {
36 $value = read_file $path;
37 }
38 }
39 return $value;
40 }
41
42 sub mac {
43 my $ip = shift;
44 my $mac = client::conf( $ip, 'mac' );
45 $mac =~ s{(..)}{$1:}g;
46 $mac =~ s{:$}{};
47 $mac = qq|<tt>$mac</tt>| if (caller(1))[3] =~ m{^httpd};
48 return uc($mac);
49 }
50
51 1;

  ViewVC Help
Powered by ViewVC 1.1.26