/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 192 - (show annotations)
Tue Jun 17 14:43:39 2008 UTC (15 years, 9 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 #!/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 my $debug = 0;
14
15 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 my $model = A3C::Model::StrixInstance->new;
22
23 my $total = 0;
24
25 find({ no_chdir => 1, wanted => sub {
26 my $path = $File::Find::name;
27 return unless -f $_;
28 warn "? $path\n" if $debug;
29 return unless m/conf\.php$/;
30
31 $path =~ m{/etc/([^/]+)/conf\.php$} or die "can't find instance name in $path";
32 my $instance = $1;
33
34 my $data = A3C::PHP->parse_file( $path );
35
36 warn "# PHP = ", dump( $data ) if $debug;
37 $data->{instance} = $instance;
38
39 my ($ok,$msg) = $model->load_or_create( %$data );
40 if ( $ok ) {
41 Jifty->log->info("$ok $instance ", $msg || 'ADDED');
42 $total++;
43 } else {
44 Jifty->log->error("can't parse $path");
45 }
46
47 }}, $config->{dir} );
48
49 Jifty->log->info( "$total Strix instances imported" );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26