From f5903fbbb5591657e89885d4296628f607475f9c Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 13 Dec 2007 14:17:08 -0600 Subject: [PATCH] installer: location of koha-conf.xml * rewrite-config.PL now puts in installed location of koha-conf.xml in C4/Context.pm so that correct config can be found even when KOHA_CONF is not set. Note that setting KOHA_CONF will still override path set by installer. * changed references from koha.xml to koha-conf.xml --- C4/Context.pm | 55 +++++++++++++++---- C4/Search.pm | 2 +- Makefile.PL | 12 +++- .../prog/en/modules/installer/auth.tmpl | 2 +- .../prog/en/modules/installer/step2.tmpl | 4 +- members/member-password.pl | 2 +- misc/cronjobs/build_browser_and_cloud.pl | 2 +- 7 files changed, 59 insertions(+), 20 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 1b02b6391c..6591e6246b 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -71,7 +71,7 @@ C4::Context - Maintain and manipulate the context of a Koha script use C4::Context; - use C4::Context("/path/to/koha.xml"); + use C4::Context("/path/to/koha-conf.xml"); $config_value = C4::Context->config("config_variable"); @@ -86,7 +86,7 @@ C4::Context - Maintain and manipulate the context of a Koha script =head1 DESCRIPTION When a Koha script runs, it makes use of a certain number of things: -configuration settings in F, a connection to the Koha +configuration settings in F, a connection to the Koha databases, and so forth. These things make up the I in which the script runs. @@ -107,7 +107,7 @@ different contexts to search both databases. Such scripts should use the C<&set_context> and C<&restore_context> functions, below. By default, C4::Context reads the configuration from -F. This may be overridden by setting the C<$KOHA_CONF> +F. This may be overridden by setting the C<$KOHA_CONF> environment variable to the pathname of a configuration file to use. =head1 METHODS @@ -123,7 +123,7 @@ environment variable to the pathname of a configuration file to use. # config # A reference-to-hash whose keys and values are the # configuration variables and values specified in the config -# file (/etc/koha.xml). +# file (/etc/koha/koha-conf.xml). # dbh # A handle to the appropriate database for this context. # dbh_stack @@ -132,8 +132,30 @@ environment variable to the pathname of a configuration file to use. # Zconn # A connection object for the Zebra server -use constant CONFIG_FNAME => "/etc/koha.xml"; +# Koha's main configuration file koha-conf.xml +# is searched for according to this priority list: +# +# 1. Path supplied via use C4::Context '/path/to/koha-conf.xml' +# 2. Path supplied in KOHA_CONF environment variable. +# 3. Path supplied in INSTALLED_CONFIG_FNAME, as long +# as value has changed from its default of +# '__KOHA_CONF_DIR__/koha-conf.xml', as happens +# when Koha is installed in 'standard' or 'single' +# mode. +# 4. Path supplied in CONFIG_FNAME. +# +# The first entry that refers to a readable file is used. + +use constant CONFIG_FNAME => "/etc/koha/koha-conf.xml"; # Default config file, if none is specified + +my $INSTALLED_CONFIG_FNAME = '__KOHA_CONF_DIR__/koha-conf.xml'; + # path to config file set by installer + # __KOHA_CONF_DIR__ is set by rewrite-confg.PL + # when Koha is installed in 'standard' or 'single' + # mode. If Koha was installed in 'dev' mode, + # __KOHA_CONF_DIR__ is *not* rewritten; instead + # developers should set the KOHA_CONF environment variable $context = undef; # Initially, no context is set @context_stack = (); # Initially, no saved contexts @@ -167,7 +189,7 @@ Reads the specified Koha config file. Returns an object containing the configuration variables. The object's structure is a bit complex to the uninitiated ... take a look at the -koha.xml file as well as the XML::Simple documentation for details. Or, +koha-conf.xml file as well as the XML::Simple documentation for details. Or, here are a few examples that may give you what you need: The simple elements nested within the element: @@ -223,11 +245,11 @@ sub import { =item new $context = new C4::Context; - $context = new C4::Context("/path/to/koha.xml"); + $context = new C4::Context("/path/to/koha-conf.xml"); Allocates a new context. Initializes the context from the specified file, which defaults to either the file given by the C<$KOHA_CONF> -environment variable, or F. +environment variable, or F. C<&new> does not set this context as the new default context; for that, use C<&set_context>. @@ -250,7 +272,18 @@ sub new { { # If the $KOHA_CONF environment variable is set, use # that. Otherwise, use the built-in default. - $conf_fname = $ENV{"KOHA_CONF"} || CONFIG_FNAME; + if (exists $ENV{"KOHA_CONF"} and $ENV{'KOHA_CONF'} and -e $ENV{"KOHA_CONF"} and -s $ENV{"KOHA_CONF"}) { + $conf_fname = $ENV{"KOHA_CONF"}; + } elsif ($INSTALLED_CONFIG_FNAME !~ /__KOHA_CONF_DIR/ and -e $INSTALLED_CONFIG_FNAME and -s $INSTALLED_CONFIG_FNAME) { + # NOTE: be careful -- don't change __KOHA_CONF_DIR in the above + # regex to anything else -- don't want installer to rewrite it + $conf_fname = $INSTALLED_CONFIG_FNAME; + } elsif (-e CONFIG_FNAME and -s CONFIG_FNAME) { + $conf_fname = CONFIG_FNAME; + } else { + warn "unable to locate Koha configuration file koha-conf.xml"; + return undef; + } } # Load the desired config file. $self = read_config_file($conf_fname); @@ -447,7 +480,7 @@ creates one and connects. C<$self> -C<$server> one of the servers defined in the koha.xml file +C<$server> one of the servers defined in the koha-conf.xml file C<$async> whether this is a asynchronous connection @@ -478,7 +511,7 @@ $context->{"Zconn"} = &_new_Zconn($server,$async); Internal function. Creates a new database connection from the data given in the current context and returns it. -C<$server> one of the servers defined in the koha.xml file +C<$server> one of the servers defined in the koha-conf.xml file C<$async> whether this is a asynchronous connection diff --git a/C4/Search.pm b/C4/Search.pm index ce7d4eeb9e..3b52cae876 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -158,7 +158,7 @@ this function performs a simple search on the catalog using zoom. =item C * $query could be a simple keyword or a complete CCL query wich is depending on your ccl file. - * @servers is optionnal. default one is read on koha.xml + * @servers is optionnal. default one is read on koha-conf.xml =item C * $error is a string which containt the description error if there is one. Else it's empty. diff --git a/Makefile.PL b/Makefile.PL index a1f2c0c6f5..c529ad0cab 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -403,9 +403,15 @@ my $pl_files = { if ($config{'INSTALL_ZEBRA'} eq "yes") { push @{ $pl_files->{'rewrite-config.PL'} }, ( - 'blib/ZEBRA_CONF_DIR/etc/passwd', - 'blib/ZEBRA_CONF_DIR/zebra-biblios.cfg', - 'blib/ZEBRA_CONF_DIR/zebra-authorities.cfg' + 'blib/ZEBRA_CONF_DIR/etc/passwd', + 'blib/ZEBRA_CONF_DIR/zebra-biblios.cfg', + 'blib/ZEBRA_CONF_DIR/zebra-authorities.cfg' + ); +} + +if ($config{'INSTALL_MODE'} ne "dev") { + push @{ $pl_files->{'rewrite-config.PL'} }, ( + 'blib/PERL_MODULE_DIR/C4/Context.pm' ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/auth.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/auth.tmpl index 45ca58793d..0cb8092f8a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/auth.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/auth.tmpl @@ -35,7 +35,7 @@

Welcome to the Koha Web Installer

Before we begin, please verify you have the correct credentials to continue. Please log in with the username and password given to you by your systems administrator and located in your -koha.xml configuration file.

+koha-conf.xml configuration file.

Please enter your username and password:

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step2.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step2.tmpl index 2348203820..aa8f02b377 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step2.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step2.tmpl @@ -36,8 +36,8 @@

  • Check that your database is running.
  • -
  • Check your database settings in koha.xml.
  • -
  • Check the hostname setting in koha.xml. +
  • Check your database settings in koha-conf.xml.
  • +
  • Check the hostname setting in koha-conf.xml. Some database servers require 127.0.0.1 rather than localhost.

Please correct these errors and start the installer again. diff --git a/members/member-password.pl b/members/member-password.pl index 62adb79aa5..183d2d3484 100755 --- a/members/member-password.pl +++ b/members/member-password.pl @@ -40,7 +40,7 @@ my $errormsg; my ($bor)=GetMember($member); if(( $member ne $loggedinuser ) && ($bor->{'category_type'} eq 'S' ) ) { $errormsg = 'NOPERMISSION' unless($staffflags->{'superlibrarian'} || $staffflags->{'staffaccess'} ); - # need superlibrarian for koha.xml fakeuser. + # need superlibrarian for koha-conf.xml fakeuser. } my $newpassword = $input->param('newpassword'); my $minpw = C4::Context->preference('minPasswordLength'); diff --git a/misc/cronjobs/build_browser_and_cloud.pl b/misc/cronjobs/build_browser_and_cloud.pl index 02ddcb0e9b..d8045d6b28 100755 --- a/misc/cronjobs/build_browser_and_cloud.pl +++ b/misc/cronjobs/build_browser_and_cloud.pl @@ -34,7 +34,7 @@ if ($version || (!$confirm)) { -t TTT to define the MARC fields/subfield to use to fill the tag cloud. If not defined, the cloud table won't be filled. example : - export PERL5LIB=/path/to/koha;export KOHA_CONF=/etc/koha.xml;./build_browser_and_cloud.pl -b -f 676a -t 606 -c + export PERL5LIB=/path/to/koha;export KOHA_CONF=/etc/koha/koha-conf.xml;./build_browser_and_cloud.pl -b -f 676a -t 606 -c EOF ; exit; -- 2.39.5