18 |
|
|
19 |
my $config = Jifty->config->app('strix') or die "need strix config"; |
my $config = Jifty->config->app('strix') or die "need strix config"; |
20 |
|
|
21 |
my $model = A3C::Model::StrixSite->new; |
my $model = A3C::Model::StrixInstance->new; |
22 |
|
|
23 |
my $total = 0; |
my $total = 0; |
24 |
|
|
28 |
warn "? $path\n" if $debug; |
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 instance name in $path"; |
32 |
my $site = $1; |
my $instance = $1; |
33 |
|
|
34 |
my $data = A3C::PHP->parse_file( $path ); |
my $data = A3C::PHP->parse_file( $path ); |
35 |
|
|
36 |
warn "# PHP = ", dump( $data ) if $debug; |
warn "# PHP = ", dump( $data ) if $debug; |
37 |
$data->{site} = $site; |
$data->{instance} = $instance; |
38 |
|
|
39 |
my ($id,$msg) = $model->load_or_create( %$data ); |
my ($ok,$msg) = $model->load_or_create( %$data ); |
40 |
Jifty->log->info("$id $site ", $msg || 'ADDED'); |
if ( $ok ) { |
41 |
if ( $id ) { |
Jifty->log->info("$ok $instance ", $msg || 'ADDED'); |
42 |
$total++; |
$total++; |
43 |
} else { |
} else { |
44 |
Jifty->log->error("can't parse $path: $msg"); |
Jifty->log->error("can't parse $path"); |
45 |
} |
} |
46 |
|
|
47 |
}}, $config->{dir} ); |
}}, $config->{dir} ); |
48 |
|
|
49 |
Jifty->log->info( "$total Strix sites imported" ); |
Jifty->log->info( "$total Strix instances imported" ); |