6 # Default config file, if none is specified
7 use constant CONFIG_FNAME
=> "/etc/koha/koha-conf.xml";
9 # path to config file set by installer
10 # __KOHA_CONF_DIR__ is set by rewrite-confg.PL
11 # when Koha is installed in 'standard' or 'single'
12 # mode. If Koha was installed in 'dev' mode,
13 # __KOHA_CONF_DIR__ is *not* rewritten; instead
14 # developers should set the KOHA_CONF environment variable
15 my $INSTALLED_CONFIG_FNAME = '__KOHA_CONF_DIR__/koha-conf.xml';
17 # Should not be called outside of C4::Context or Koha::Cache
18 # use C4::Context->config instead
20 my ( $class, $file ) = @_;
21 return XMLin
($file, keyattr
=> ['id'], forcearray
=> ['listen', 'server', 'serverinfo'], suppressempty
=> '');
24 # Koha's main configuration file koha-conf.xml
25 # is searched for according to this priority list:
27 # 1. Path supplied via use C4::Context '/path/to/koha-conf.xml'
28 # 2. Path supplied in KOHA_CONF environment variable.
29 # 3. Path supplied in INSTALLED_CONFIG_FNAME, as long
30 # as value has changed from its default of
31 # '__KOHA_CONF_DIR__/koha-conf.xml', as happens
32 # when Koha is installed in 'standard' or 'single'
34 # 4. Path supplied in CONFIG_FNAME.
36 # The first entry that refers to a readable file is used.
40 # If the $KOHA_CONF environment variable is set, use
41 # that. Otherwise, use the built-in default.
43 if ( exists $ENV{"KOHA_CONF"} and $ENV{'KOHA_CONF'} and -s
$ENV{"KOHA_CONF"} ) {
44 $conf_fname = $ENV{"KOHA_CONF"};
45 } elsif ( $INSTALLED_CONFIG_FNAME !~ /__KOHA_CONF_DIR/ and -s
$INSTALLED_CONFIG_FNAME ) {
46 # NOTE: be careful -- don't change __KOHA_CONF_DIR in the above
47 # regex to anything else -- don't want installer to rewrite it
48 $conf_fname = $INSTALLED_CONFIG_FNAME;
49 } elsif ( -s CONFIG_FNAME
) {
50 $conf_fname = CONFIG_FNAME
;