use lib '/opt/eprints/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";
		}
	}
}
######################################################################
#
#  This file is part of GNU EPrints 2.
#  
#  Copyright (c) 2000-2004 University of Southampton, UK. SO17 1BJ.
#  
#  EPrints 2 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 2 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 2; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
######################################################################

## Apache::DBI MUST come before other modules using DBI or
## you won't get constant connections and everything
## will go horribly wrong...

use Carp qw(verbose);

use EPrints::Apache::AnApache;

use Apache::DBI;
#$Apache::DBI::DEBUG = 3;

$ENV{MOD_PERL} or EPrints::Config::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::Archive->new_archive_by_id( $_ );
}
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;
