symlinks now return location which they point to
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 21 Jul 2010 16:49:29 +0000 (16:49 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 21 Jul 2010 16:49:29 +0000 (16:49 +0000)
This allows to specify configuration options, like
memdisk.image as simple symlinks directly to files

lib/PXElator/client.pm

index daab34a..066867c 100644 (file)
@@ -62,6 +62,8 @@ sub conf {
                write_file $path, $default;
                warn "default $path = $default";
                $value = $default;
+       } elsif ( -l $path ) {
+               $value = readlink $path;
        } elsif ( -f $path ) {
                $value = read_file $path;
                chomp $value;
@@ -78,7 +80,10 @@ sub all_conf {
        foreach my $file ( glob("$path/*"), glob("$path/*/*") ) {
                my $name = $file;
                $name =~ s{^$path/+}{} || die "can't remove $path from $name";
-               $conf->{ $name } = read_file $file if -f $file;
+               $conf->{ $name } =
+                       -l $file ? readlink  $file :
+                       -f $file ? read_file $file :
+                       '?';
        }
        return $conf;
 }