/[A3C]/bin/import-strix-config.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /bin/import-strix-config.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 192 - (hide annotations)
Tue Jun 17 14:43:39 2008 UTC (12 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 1023 byte(s)
rename import-strix.pl to import-strix-config.pl
because it well, imports config from php files
1 dpavlin 139 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6     use lib 'lib';
7    
8     use Jifty;
9     use Data::Dump qw/dump/;
10     use File::Find;
11     use A3C::PHP;
12    
13 dpavlin 146 my $debug = 0;
14    
15 dpavlin 139 BEGIN { Jifty->new; };
16     Jifty->web->request(Jifty::Request->new);
17     Jifty->web->response(Jifty::Response->new);
18    
19     my $config = Jifty->config->app('strix') or die "need strix config";
20    
21 dpavlin 174 my $model = A3C::Model::StrixInstance->new;
22 dpavlin 139
23     my $total = 0;
24    
25     find({ no_chdir => 1, wanted => sub {
26     my $path = $File::Find::name;
27     return unless -f $_;
28 dpavlin 146 warn "? $path\n" if $debug;
29 dpavlin 139 return unless m/conf\.php$/;
30    
31 dpavlin 174 $path =~ m{/etc/([^/]+)/conf\.php$} or die "can't find instance name in $path";
32     my $instance = $1;
33 dpavlin 139
34     my $data = A3C::PHP->parse_file( $path );
35    
36 dpavlin 146 warn "# PHP = ", dump( $data ) if $debug;
37 dpavlin 174 $data->{instance} = $instance;
38 dpavlin 139
39 dpavlin 147 my ($ok,$msg) = $model->load_or_create( %$data );
40     if ( $ok ) {
41 dpavlin 174 Jifty->log->info("$ok $instance ", $msg || 'ADDED');
42 dpavlin 146 $total++;
43     } else {
44 dpavlin 147 Jifty->log->error("can't parse $path");
45 dpavlin 146 }
46 dpavlin 139
47     }}, $config->{dir} );
48    
49 dpavlin 174 Jifty->log->info( "$total Strix instances imported" );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26