3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 # Default config file, if none is specified
23 use constant CONFIG_FNAME => "/etc/koha/koha-conf.xml";
25 # path to config file set by installer
26 # __KOHA_CONF_DIR__ is set by rewrite-confg.PL
27 # when Koha is installed in 'standard' or 'single'
28 # mode. If Koha was installed in 'dev' mode,
29 # __KOHA_CONF_DIR__ is *not* rewritten; instead
30 # developers should set the KOHA_CONF environment variable
31 my $INSTALLED_CONFIG_FNAME = '__KOHA_CONF_DIR__/koha-conf.xml';
33 # Should not be called outside of C4::Context or Koha::Cache
34 # use C4::Context->config instead
36 my ( $class, $file ) = @_;
38 return if not defined $file;
45 forcearray => ['listen', 'server', 'serverinfo'],
51 die "\nError reading file $file.\nTry running this again as the koha instance user (or use the koha-shell command in debian)\n\n";
57 # Koha's main configuration file koha-conf.xml
58 # is searched for according to this priority list:
60 # 1. Path supplied via use C4::Context '/path/to/koha-conf.xml'
61 # 2. Path supplied in KOHA_CONF environment variable.
62 # 3. Path supplied in INSTALLED_CONFIG_FNAME, as long
63 # as value has changed from its default of
64 # '__KOHA_CONF_DIR__/koha-conf.xml', as happens
65 # when Koha is installed in 'standard' or 'single'
67 # 4. Path supplied in CONFIG_FNAME.
69 # The first entry that refers to a readable file is used.
73 # If the $KOHA_CONF environment variable is set, use
74 # that. Otherwise, use the built-in default.
76 if ( exists $ENV{"KOHA_CONF"} and $ENV{'KOHA_CONF'} and -s $ENV{"KOHA_CONF"} ) {
77 $conf_fname = $ENV{"KOHA_CONF"};
78 } elsif ( $INSTALLED_CONFIG_FNAME !~ /__KOHA_CONF_DIR/ and -s $INSTALLED_CONFIG_FNAME ) {
79 # NOTE: be careful -- don't change __KOHA_CONF_DIR in the above
80 # regex to anything else -- don't want installer to rewrite it
81 $conf_fname = $INSTALLED_CONFIG_FNAME;
82 } elsif ( -s CONFIG_FNAME ) {
83 $conf_fname = CONFIG_FNAME;