50 |
} |
} |
51 |
|
|
52 |
my $path = ip_path $ip; |
my $path = ip_path $ip; |
53 |
mkdir $path unless -d $path; |
mkdir $path unless -e $path; |
54 |
|
warn "WARNING: $path not directory" unless -d $path; |
55 |
$path .= '/' . $name; |
$path .= '/' . $name; |
56 |
|
|
57 |
if ( defined $value ) { |
if ( defined $value ) { |
63 |
write_file $path, $default; |
write_file $path, $default; |
64 |
warn "default $path = $default"; |
warn "default $path = $default"; |
65 |
$value = $default; |
$value = $default; |
66 |
|
} elsif ( -l $path ) { |
67 |
|
$value = readlink $path; |
68 |
} elsif ( -f $path ) { |
} elsif ( -f $path ) { |
69 |
$value = read_file $path; |
$value = read_file $path; |
70 |
chomp $value; |
chomp $value; |
81 |
foreach my $file ( glob("$path/*"), glob("$path/*/*") ) { |
foreach my $file ( glob("$path/*"), glob("$path/*/*") ) { |
82 |
my $name = $file; |
my $name = $file; |
83 |
$name =~ s{^$path/+}{} || die "can't remove $path from $name"; |
$name =~ s{^$path/+}{} || die "can't remove $path from $name"; |
84 |
$conf->{ $name } = read_file $file if -f $file; |
next if -d $file; |
85 |
|
$conf->{ $name } = |
86 |
|
-l $file ? readlink $file : |
87 |
|
-f $file ? read_file $file : |
88 |
|
'?'; |
89 |
} |
} |
90 |
return $conf; |
return $conf; |
91 |
} |
} |