/[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

Annotation of /lib/PXElator/client.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 164 - (hide annotations)
Thu Aug 6 18:43:55 2009 UTC (14 years, 9 months ago) by dpavlin
File size: 747 byte(s)
read symlink destination istead of content

1 dpavlin 156 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 dpavlin 164 } elsif ( -e $path ) {
32     if ( -l $path ) {
33     $value = readlink $path;
34     $value =~ s{.*/([^/]+)$}{$1};
35     } else {
36     $value = read_file $path;
37     }
38 dpavlin 156 }
39     return $value;
40     }
41    
42     1;

  ViewVC Help
Powered by ViewVC 1.1.26