10 |
use File::Find; |
use File::Find; |
11 |
use A3C::PHP; |
use A3C::PHP; |
12 |
|
|
13 |
|
my $debug = 0; |
14 |
|
|
15 |
BEGIN { Jifty->new; }; |
BEGIN { Jifty->new; }; |
16 |
Jifty->web->request(Jifty::Request->new); |
Jifty->web->request(Jifty::Request->new); |
17 |
Jifty->web->response(Jifty::Response->new); |
Jifty->web->response(Jifty::Response->new); |
25 |
find({ no_chdir => 1, wanted => sub { |
find({ no_chdir => 1, wanted => sub { |
26 |
my $path = $File::Find::name; |
my $path = $File::Find::name; |
27 |
return unless -f $_; |
return unless -f $_; |
28 |
warn "? $path\n"; |
warn "? $path\n" if $debug; |
29 |
return unless m/conf\.php$/; |
return unless m/conf\.php$/; |
30 |
|
|
31 |
$path =~ m{/etc/([^/]+)/conf\.php$} or die "can't find site name in $path"; |
$path =~ m{/etc/([^/]+)/conf\.php$} or die "can't find site name in $path"; |
33 |
|
|
34 |
my $data = A3C::PHP->parse_file( $path ); |
my $data = A3C::PHP->parse_file( $path ); |
35 |
|
|
36 |
warn "# PHP = ", dump( $data ); |
warn "# PHP = ", dump( $data ) if $debug; |
37 |
$data->{site} = $site; |
$data->{site} = $site; |
38 |
|
|
39 |
my ($id,$msg) = $model->load_or_create( %$data ); |
my ($id,$msg) = $model->load_or_create( %$data ); |
40 |
warn "$id $site ", $msg || 'ADDED', "\n"; |
Jifty->log->info("$id $site ", $msg || 'ADDED'); |
41 |
$total++ if $id; |
if ( $id ) { |
42 |
|
$total++; |
43 |
|
} else { |
44 |
|
Jifty->log->error("can't parse $path: $msg"); |
45 |
|
} |
46 |
|
|
47 |
}}, $config->{dir} ); |
}}, $config->{dir} ); |
48 |
|
|