8 use Text::Tradition::Directory;
10 binmode STDOUT, ':utf8';
11 binmode STDERR, ':utf8';
12 eval { no warnings; binmode $DB::OUT, ':utf8'; $DB::deep = 1000 };
16 DBHOST => '127.0.0.1',
18 DBNAME => 'idpresult',
25 if( -f "/etc/graphcalc.conf" ) {
26 # Read the variables in from here.
27 open( GCCONF, "/etc/graphcalc.conf" )
28 or die "Could not open configuration file /etc/graphcalc.conf";
32 my( $name, $val ) = split( /\s*\=\s*/, $_ );
33 if( exists $VARS{$name} ) {
39 unless( $VARS{DSN} ) {
40 $VARS{DSN} = sprintf( "dbi:%s:dbname=%s;host=%s;port=%s",
41 $VARS{DBTYPE}, $VARS{DBNAME}, $VARS{DBHOST}, $VARS{DBPORT} );
45 $dirargs->{user} = $VARS{DBUSER} if $VARS{DBUSER};
46 $dirargs->{password} = $VARS{DBPASS} if $VARS{DBPASS};
47 my $dir = Text::Tradition::Directory->new(
48 'dsn' => $VARS{DSN}, 'extra_args' => $dirargs );
50 my $scope = $dir->new_scope();
51 my $dumpfile = $VARS{TMPDIR}.'/idpbackup.json';
52 open( IDPBACKUP, ">$dumpfile" )
53 or die "Could not open dump file $dumpfile for writing";
54 binmode IDPBACKUP, ':utf8';
56 say IDPBACKUP JSON->new->allow_blessed->convert_blessed->encode( @_ );