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

Diff of /lib/PXElator/client.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 412 by dpavlin, Wed Sep 9 13:40:45 2009 UTC revision 510 by dpavlin, Wed Jul 21 16:49:29 2010 UTC
# Line 62  sub conf { Line 62  sub conf {
62                  write_file $path, $default;                  write_file $path, $default;
63                  warn "default $path = $default";                  warn "default $path = $default";
64                  $value = $default;                  $value = $default;
65            } elsif ( -l $path ) {
66                    $value = readlink $path;
67          } elsif ( -f $path ) {          } elsif ( -f $path ) {
68                  $value = read_file $path;                  $value = read_file $path;
69                    chomp $value;
70          } else {          } else {
71                  warn "# $name missing $path\n" if $debug;                  warn "# $name missing $path\n" if $debug;
72          }          }
# Line 74  sub all_conf { Line 77  sub all_conf {
77          my $ip = shift;          my $ip = shift;
78          my $path = ip_path $ip || return;          my $path = ip_path $ip || return;
79          my $conf;          my $conf;
80          foreach my $file ( glob("$path/*") ) {          foreach my $file ( glob("$path/*"), glob("$path/*/*") ) {
81                  my $name = $file;                  my $name = $file;
82                  $name =~ s{^.+/([^/]+)$}{$1};                  $name =~ s{^$path/+}{} || die "can't remove $path from $name";
83                  $conf->{ $name } = read_file $file;                  $conf->{ $name } =
84                            -l $file ? readlink  $file :
85                            -f $file ? read_file $file :
86                            '?';
87          }          }
88          return $conf;          return $conf;
89  }  }
# Line 173  sub all_ips { Line 179  sub all_ips {
179    
180  sub remove {  sub remove {
181          my $ip = shift;          my $ip = shift;
         unlink $_ foreach grep { -e $_ } ( glob "$server::conf/ip/$ip/*" );  
182          if ( my $mac = mac_from_ip $ip ) {          if ( my $mac = mac_from_ip $ip ) {
183                  unlink "$server::conf/mac/$mac";                  unlink "$server::conf/mac/$mac";
184          }          }
# Line 202  sub rebuild_mac_links { Line 207  sub rebuild_mac_links {
207                  my $mac = ip_path $ip, 'mac';                  my $mac = ip_path $ip, 'mac';
208                  if ( -e $mac ) {                  if ( -e $mac ) {
209                          $mac = read_file $mac;                          $mac = read_file $mac;
210                            chomp $mac;
211                          save_ip_mac( $ip, $mac );                          save_ip_mac( $ip, $mac );
212                          warn "## $ip $mac\n";                          warn "## $ip $mac\n";
213                  }                  }

Legend:
Removed from v.412  
changed lines
  Added in v.510

  ViewVC Help
Powered by ViewVC 1.1.26