From e449c139fff95241bd3b9f1ddfc506d786a6e9a6 Mon Sep 17 00:00:00 2001 From: MJ Ray Date: Thu, 6 Sep 2007 14:56:03 +0100 Subject: [PATCH] Add configuration file helper to the installer Signed-off-by: Chris Cormack --- C4/Context.pm | 3 +- Makefile.PL | 28 +++++++- etc/README.txt | 20 ++++++ {misc/zebra => etc}/ccl.properties | 0 etc/cql.properties | 45 +++++++++++++ etc/koha-conf.xml | 50 ++++++++++++++ etc/koha-httpd.conf | 59 ++++++++++++++++ {misc/zebra => etc}/pqf.properties | 0 etc/zebra-authorities.cfg | 46 +++++++++++++ etc/zebra-biblios.cfg | 42 ++++++++++++ rewrite-config.PL | 105 +++++++++++++++++++++++++++++ 11 files changed, 393 insertions(+), 5 deletions(-) create mode 100644 etc/README.txt rename {misc/zebra => etc}/ccl.properties (100%) create mode 100644 etc/cql.properties create mode 100644 etc/koha-conf.xml create mode 100644 etc/koha-httpd.conf rename {misc/zebra => etc}/pqf.properties (100%) create mode 100644 etc/zebra-authorities.cfg create mode 100644 etc/zebra-biblios.cfg create mode 100644 rewrite-config.PL diff --git a/C4/Context.pm b/C4/Context.pm index e762aa58df..6451828ebf 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -28,8 +28,7 @@ use vars qw($VERSION $AUTOLOAD), qw($context), qw(@context_stack); -$VERSION = do { my @v = '$Revision$' =~ /\d+/g; - shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); }; +$VERSION = '3.00.00.002'; =head1 NAME diff --git a/Makefile.PL b/Makefile.PL index 3b2ae2371a..e1ccca8c32 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -47,7 +47,7 @@ and generate configuration files. =head1 VARIABLES -=head2 NAME, VERSION, ABSTRACT, AUTHOR +=head2 NAME, VERSION_FROM, ABSTRACT, AUTHOR Basic metadata about this software. @@ -79,7 +79,8 @@ to generate initial configuration files. WriteMakefile( NAME => 'koha', - VERSION => strftime('2.9.%Y%m%d%H',gmtime), + #VERSION => strftime('2.9.%Y%m%d%H',gmtime), + VERSION_FROM => 'C4/Context.pm', ABSTRACT => 'Award-winning integrated library system (ILS) and Web OPAC', AUTHOR => 'Koha Developers ', NO_META => 1, @@ -150,7 +151,14 @@ WriteMakefile( # return { macro => { 'export TEST' => '755' } } # }, -# PL_FILES => { # generator => target + PL_FILES => { # generator => target(s) + 'rewrite-config.PL' => [ + '$(INST_LIBDIR)/koha/etc/koha-conf.xml', + '$(INST_LIBDIR)/koha/etc/koha-httpd.conf', + '$(INST_LIBDIR)/koha/etc/zebra-biblios.cfg', + '$(INST_LIBDIR)/koha/etc/zebra-authorities.cfg' + ] + } # 'opac/getfromintranet.PL' => ['$(INST_LIBDIR)/opac/cgi-bin/detail.pl','$(INST_LIBDIR)/opac/cgi-bin/moredetail.pl','$(INST_LIBDIR)/opac/cgi-bin/search.pl','$(INST_LIBDIR)/opac/cgi-bin/subjectsearch.pl','$(INST_LIBDIR)/opac/cgi-bin/logout.pl'], # 'misc/koha.conf.PL' => '$(INST_LIBDIR)/../etc/koha.conf', # 'misc/apache-koha.conf.PL' => '$(INST_LIBDIR)/../etc/apache-koha.conf', @@ -217,6 +225,16 @@ excluding non-files, CVS files and whitespace in filenames. $result{$src} = '$(INST_LIBDIR)/koha/templates/'.$src; } } +=pod + +etc files are copied to koha/etc + +=cut + # Misc etc to koha/etc + foreach my $src (glob("etc/*")) { + $result{$src} = '$(INST_LIBDIR)/koha/'.$src; + } + return \%result; } @@ -228,5 +246,9 @@ __END__ ExtUtils::MakeMaker(3) +=head1 AUTHOR + +MJ Ray mjr at phonecoop.coop + =cut diff --git a/etc/README.txt b/etc/README.txt new file mode 100644 index 0000000000..01356a674e --- /dev/null +++ b/etc/README.txt @@ -0,0 +1,20 @@ + +Koha Configuration Files: + +The following files specify the base configuration for Koha ZOOM: + + * koha-httpd.conf +In a debian system, this apache configuration file will be symlinked +from /etc/apache2/sites-enabled +Specify Koha's IP address with NameVirtualHost +Set ServerName, etc + + * koha-production.xml + * koha-testing.xml +These are the production and testing configurations for zebrasrv and for Koha. +The first part of each file specifies Zebra server names, indexing configuration files, +and query language configurations. Koha configuration directives follow. + + * zebra-authorities.cfg + * zebra-biblios.cfg + diff --git a/misc/zebra/ccl.properties b/etc/ccl.properties similarity index 100% rename from misc/zebra/ccl.properties rename to etc/ccl.properties diff --git a/etc/cql.properties b/etc/cql.properties new file mode 100644 index 0000000000..c61de4411d --- /dev/null +++ b/etc/cql.properties @@ -0,0 +1,45 @@ +# CCL field mappings +# $Id: default.bib,v 1.1 2006/06/13 16:44:21 mike Exp $ +# +# The rule below is used when no fields are specified +term t=l,r s=al +# +# Simple rule for a field called "clean" +clean t=l,r +# +# Rules for some BIB-1 fields +au u=1003 s=pw +ti u=4 s=pw +isbn u=7 +issn u=8 +cc u=20 +su u=21 s=pw +date u=30 r=r +dp u=31 r=r +da u=32 r=r +la u=54 s=pw +ab u=62 s=pw +note u=63 s=pw +af u=1006 s=pw +# +# Rules for a few GILS fields +north gils-attset,u=2040 r=o +south gils-attset,u=2041 r=o +east gils-attset,u=2038 r=o +west gils-attest,u=2039 r=o +distributor gils-attset,u=2000 s=pw +distributorname gils-attset,u=2001 s=pw + +# Explain fields +ExplainCategory exp1,1=1 +HumanStringLanguage exp1,1=2 +DatabaseName exp1,1=3 +TargetName exp1,1=4 +AttributeSetOID exp1,1=5 +RecordSyntaxOID exp1,1=6 +TagSetOID exp1,1=7 +ExtededServiceOID exp1,1=8 +DateAdded exp1,1=9 +DateChanged exp1,1=10 +DateExpires exp1,1=11 +ElementSetName exp1,1=12 diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml new file mode 100644 index 0000000000..ff7cc2e0fc --- /dev/null +++ b/etc/koha-conf.xml @@ -0,0 +1,50 @@ + + + + + +unix:__BASE_DIR__/tmp/bibliosocket +unix:__BASE_DIR__/tmp/authoritysocket + + + + + + __BASE_DIR__/zebradb/biblios + __BASE_DIR__/etc/zebra-biblios.cfg + __BASE_DIR__/etc/pqf.properties + + + __BASE_DIR__/ccl.properties + __ZEBRA_USER__ + __ZEBRA_PASS__ + + + + + __BASE_DIR__/zebradb/authorities + __BASE_DIR__/etc/zebra-authorities.cfg + + + __BASE_DIR__/etc/ccl.properties + __ZEBRA_USER__ + __ZEBRA_PASS__ + + + + + __MYSQL_DB__ + __MYSQL_HOST__ + __MYSQL_USER__ + __MYSQL_PASS__ + biblios + 1 + authorities + 1 + __BASE_DIR__/intranet/cgi-bin + __BASE_DIR__/opac/cgi-bin + __BASE_DIR__/opac/htdocs/opac-tmpl + __BASE_DIR__/intranet/htdocs/intranet-tmpl + __BASE_DIR__/intranet/htdocs/intranet-tmpl/default/en/includes/ + + diff --git a/etc/koha-httpd.conf b/etc/koha-httpd.conf new file mode 100644 index 0000000000..78ed84823b --- /dev/null +++ b/etc/koha-httpd.conf @@ -0,0 +1,59 @@ +# Koha Apache Configuration Directives + +#NameVirtualHost * + +## OPAC + + ServerAdmin webmaster@__WEBSERVER_DOMAIN__ + DocumentRoot __BASE_DIR__/opac/htdocs + ServerName __WEBSERVER_HOST__ +# ServerAlias opac.mydomain.com + ScriptAlias /cgi-bin/koha/ "__BASE_DIR__/opac/cgi-bin/" + ScriptAlias /index.html "__BASE_DIR__/opac/cgi-bin/opac-main.pl" + ScriptAlias /opac-search.pl "__BASE_DIR__/opac/cgi-bin/search" + ScriptAlias /search "__BASE_DIR__/opac/cgi-bin/search" + ErrorLog __BASE_DIR__/log/opac-error_log +# TransferLog __BASE_DIR__/log/opac-access_log + SetEnv PERL5LIB "__BASE_DIR__/intranet/modules" + SetEnv KOHA_CONF "__BASE_DIR__/etc/koha-conf.xml" + Options +FollowSymLinks + +# Rewrite Rules + RewriteEngine On + +# Uncomment to turn on rewrite logging +# RewriteLog __BASE_DIR__/log/opac-rewrite.log +# RewriteLogLevel 1 + RewriteCond %{QUERY_STRING} (.*?)(?:[A-Za-z0-9_-]+)=&(.*) + RewriteRule (.+) $1?%1%2 [N,R,NE] + + RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/opac-detail\.pl?bib=$1 [PT] + RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT] + RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT] + + +## Intranet + + ServerAdmin webmaster@__WEBSERVER_DOMAIN__ + DocumentRoot __BASE_DIR__/intranet/htdocs + ServerName __WEBSERVER_HOST__:8080 +# ServerAlias intranet.mydomain.com + ScriptAlias /cgi-bin/koha/ "__BASE_DIR__/intranet/cgi-bin/" + ScriptAlias /index.html "__BASE_DIR__/intranet/cgi-bin/mainpage.pl" + ScriptAlias /search "__BASE_DIR__/intranet/cgi-bin/search.pl" + ErrorLog __BASE_DIR__/log/error_log +# TransferLog __BASE_DIR__/log/access_log + SetEnv PERL5LIB "__BASE_DIR__/intranet/modules" + SetEnv KOHA_CONF "__BASE_DIR__/etc/koha-conf.xml" + Options +FollowSymLinks + RewriteEngine On +# Uncomment to turn on rewrite logging +# RewriteLog __BASE_DIR__/log/intranet-rewrite.log +# RewriteLogLevel 1 + + RewriteCond %{QUERY_STRING} (.*?)(?:[A-Za-z0-9_-]+)=&(.*) + RewriteRule (.+) $1?%1%2 [N,R,NE] + RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/detail\.pl?bib=$1 [PT] + RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT] + RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT] + diff --git a/misc/zebra/pqf.properties b/etc/pqf.properties similarity index 100% rename from misc/zebra/pqf.properties rename to etc/pqf.properties diff --git a/etc/zebra-authorities.cfg b/etc/zebra-authorities.cfg new file mode 100644 index 0000000000..fe887965e9 --- /dev/null +++ b/etc/zebra-authorities.cfg @@ -0,0 +1,46 @@ + +# Simple Zebra configuration file that defines +# a database with MARCXML records. +# $Id: zebra.cfg,v 1.1.2.2 2006/05/09 12:03:16 rangi Exp $ +# +# Where are the config files located? +profilePath:__BASE_DIR__/zebradb/authorities/tab:__BASE_DIR__/zebradb/tab + +encoding: UTF-8 +# modulePath - where to look for loadable zebra modules +modulePath: /usr/lib/idzebra-2.0/modules + +# Files that describe the attribute sets supported. +attset: bib1.att +attset: explain.att +attset:gils.att + +#systag sysno rank +# Specify record type +iso2709.recordType:grs.marcxml.record +recordType:grs.xml +recordId: (bib1,Local-Number) +# was auth1 +storeKeys:1 +storeData:1 + + +# Lock File Area +lockDir: __BASE_DIR__/zebradb/authorities/lock +perm.anonymous:r +perm.kohaadmin:rw +passw.kohalis +shadow +register: __BASE_DIR__/zebradb/authorities/register:4G +shadow: __BASE_DIR__/zebradb/authorities/shadow:1G + +# Temp File area for result sets +setTmpDir: __BASE_DIR__/zebradb/authorities/tmp + +# Temp File area for index program +keyTmpDir: __BASE_DIR__/zebradb/authorities/key + +# Approx. Memory usage during indexing +memMax: 200M +rank:rank-1 + diff --git a/etc/zebra-biblios.cfg b/etc/zebra-biblios.cfg new file mode 100644 index 0000000000..a70d51074d --- /dev/null +++ b/etc/zebra-biblios.cfg @@ -0,0 +1,42 @@ +# Simple Zebra configuration file that defines +# a database with MARCXML records. +# $Id: zebra.cfg,v 1.1.2.2 2006/05/09 12:03:16 rangi Exp $ +# +# Where are the config files located? +profilePath:__BASE_DIR__/zebradb/biblios/tab:__BASE_DIR__/zebradb/tab +# modulePath - where to look for loadable zebra modules +modulePath: /usr/lib/idzebra-2.0/modules + +encoding: UTF-8 +# Files that describe the attribute sets supported. +attset: bib1.att +attset: explain.att +attset:gils.att + +# systag sysno rank +# Specify record type +iso2709.recordType:grs.marcxml.record +recordType:grs.xml +recordId: (bib1,Local-number) +storeKeys:1 +storeData:1 + + +# Lock File Area +lockDir: __BASE_DIR__/zebradb/biblios/lock +perm.anonymous:r +perm.kohaadmin:rw +passw.kohalis +shadow +register: __BASE_DIR__/zebradb/biblios/register:4G +shadow: __BASE_DIR__/zebradb/biblios/shadow:4G + +# Temp File area for result sets +setTmpDir: __BASE_DIR__/zebradb/biblios/tmp + +# Temp File area for index program +keyTmpDir: __BASE_DIR__/zebradb/biblios/key + +# Approx. Memory usage during indexing +memMax: 500M +rank:rank-1 diff --git a/rewrite-config.PL b/rewrite-config.PL new file mode 100644 index 0000000000..9f92467424 --- /dev/null +++ b/rewrite-config.PL @@ -0,0 +1,105 @@ +# Copyright 2007 MJ Ray +# +# This file is part of Koha. +# +# Koha 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. +# +# Koha 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 +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA +# +# Current maintainer MJR http://mjr.towers.org.uk/ +# See http://www.koha.org/wiki/?page=KohaInstaller + +use Sys::Hostname; +use Socket; + +=head1 NAME + +rewrite-config.PL - helper for the Koha packager and installer + +=head1 SYNOPSIS + + perl rewrite-config.PL configurationfile + +=head1 DESCRIPTION + +This helper script replaces placeholders in the +configuration files with value either supplied through +the environment (with export, or by putting them on +the start of the make command linke) or with reasonable +guesses worked out by the script. + +=head2 KEYS + +The following configuration keys are available: + +BASE_DIR, MYSQL_DB, MYSQL_HOST, MYSQL_PASS, MYSQL_USER, WEBSERVER_DOMAIN, +WEBSERVER_HOST, WEBSERVER_IP, ZEBRA_PASS, ZEBRA_USER + +=cut + +$myhost = hostname(); +$mydomain = $myhost; +$mydomain =~ s/^.*?\.//; + +# These are our configuration guesses +# Keys were extracted by +# "",/' +%configuration = ( + "__BASE_DIR__" => sprintf("/usr/lib/perl5/site-perl/%vd/koha",$^V), + "__MYSQL_DB__" => "koha", + "__MYSQL_HOST__" => $myhost, + "__MYSQL_PASS__" => "katikoan", + "__MYSQL_USER__" => "kohaadmin", + "__WEBSERVER_DOMAIN__" => $mydomain, + "__WEBSERVER_HOST__" => $myhost, + # This is set like this to rescue systems with broken DNS + "__WEBSERVER_IP__" => $ENV{'WEBSERVER_IP'} || inet_ntoa(scalar gethostbyname($myhost||'localhost')) || die "Cannot get our own IP address: DNS fault?", + "__ZEBRA_PASS__" => "zebrastripes", + "__ZEBRA_USER__" => "kohauser", +); + +# Override configuration from the environment +foreach $key (keys %configuration) { + if (defined($ENV{$key})) { + $configuration{$key} = $ENV{$key}; + } +} + +$fname = $ARGV[0]; +$file = read_file($fname); +$file =~ s/__.*?__/$configuration{$&}/seg; +chmod 0644, $fname; +open(OUTPUT,">$fname") || die "Can't open $fname for write: $!"; +print OUTPUT $file; +close(OUTPUT); + +# Idea taken from perlfaq5 +sub read_file($) { + local(*INPUT,$/); + open(INPUT,$_[0]) || die "Can't open $_[0] for read"; + my $file = ; + return $file; +} + +__END__ + + +=head1 SEE ALSO + +Makefile.PL, ExtUtils::MakeMaker(3) + +=head1 AUTHOR + +MJ Ray mjr at phonecoop.coop + +=cut + -- 2.20.1