use lib '/opt/eprints3/perl_lib';

BEGIN
{
	use EPrints::SystemSettings;

	my $conf_v = $ENV{EPRINTS_APACHE};
	if( defined $conf_v )
	{
		my $av =  $EPrints::SystemSettings::conf->{apache};
		$av = "1" unless defined $av;

		my $mismatch = 0;
		$mismatch = 1 if( $av eq "2" && $conf_v ne "2" );
		$mismatch = 1 if( $av ne "2" && $conf_v ne "1" );
		if( $mismatch )
		{
			print STDERR <<END;

------------------------------------------------------------
According to a flag in the Apache configuration, the part
of it relating to EPrints was generated for running with 
Apache $conf_v but this version of EPrints is configured 
to use version $av of Apache.

You should probably check the "apache" parameter setting in
perl_lib/EPrints/SystemSettings.pm then run the script
generate_apacheconf, then try to start Apache again.
------------------------------------------------------------

END
			die "Apache version mismatch";
		}
	}
}
######################################################################
#
#
# Copyright 2000-2008 University of Southampton. All Rights Reserved.
# 
#  This file is part of GNU EPrints 3.
#  
#  Copyright (c) 2000-2008 University of Southampton, UK. SO17 1BJ.
#  
#  EPrints 3 is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  EPrints 3 is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with EPrints 3; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
######################################################################

use Carp qw(verbose);

$ENV{MOD_PERL} or EPrints::abort( "not running under mod_perl!" );

use EPrints;

use strict;


EPrints::Config::ensure_init();

my %done = ();
foreach( EPrints::Config::get_repository_ids() )
{
	next if $done{$_};
	EPrints::Repository->new( $_ );
}
print STDERR "EPrints archives loaded: ".join( ", ",  EPrints::Config::get_repository_ids() )."\n";

# Tell me more about warnings
$SIG{__WARN__} = \&Carp::cluck;

$EPrints::SystemSettings::loaded = 1;
1;
