Add configuration file helper to the installer
authorMJ Ray <mjr@phonecoop.coop>
Thu, 6 Sep 2007 13:56:03 +0000 (14:56 +0100)
committerChris Cormack <crc@liblime.com>
Thu, 6 Sep 2007 22:14:40 +0000 (17:14 -0500)
Signed-off-by: Chris Cormack <crc@liblime.com>

C4/Context.pm
Makefile.PL
etc/README.txt [new file with mode: 0644]
etc/ccl.properties [moved from misc/zebra/ccl.properties with 100% similarity]
etc/cql.properties [new file with mode: 0644]
etc/koha-conf.xml [new file with mode: 0644]
etc/koha-httpd.conf [new file with mode: 0644]
etc/pqf.properties [moved from misc/zebra/pqf.properties with 100% similarity]
etc/zebra-authorities.cfg [new file with mode: 0644]
etc/zebra-biblios.cfg [new file with mode: 0644]
rewrite-config.PL [new file with mode: 0644]

index e762aa5..6451828 100644 (file)
@@ -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
 
index 3b2ae23..e1ccca8 100644 (file)
@@ -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 <koha-devel@nongnu.org>',
     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 (file)
index 0000000..01356a6
--- /dev/null
@@ -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
+
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 (file)
index 0000000..c61de44
--- /dev/null
@@ -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 (file)
index 0000000..ff7cc2e
--- /dev/null
@@ -0,0 +1,50 @@
+<yazgfs>
+<!-- [scheme:]host[:port][/databaseName] -->
+<!-- scheme: tcp, ssl, unix, http, sru -->
+<!-- can run all servers on tcp, but the unix socket is faster -->
+
+<listen id="biblioserver" >unix:__BASE_DIR__/tmp/bibliosocket</listen>
+<listen id="authorityserver" >unix:__BASE_DIR__/tmp/authoritysocket</listen>
+<!-- public server runs on tcp -->
+<!-- <listen id="publicserver" >tcp:@:9999</listen> -->
+
+<!-- BIBLIOGRAPHIC RECORDS -->
+<server id="biblioserver"  listenref="biblioserver"> 
+    <directory>__BASE_DIR__/zebradb/biblios</directory>
+    <config>__BASE_DIR__/etc/zebra-biblios.cfg</config>
+    <cql2rpn>__BASE_DIR__/etc/pqf.properties</cql2rpn>
+</server>
+<serverinfo id="biblioserver">
+        <ccl2rpn>__BASE_DIR__/ccl.properties</ccl2rpn>
+        <user>__ZEBRA_USER__</user>    
+        <password>__ZEBRA_PASS__</password>
+</serverinfo>
+
+<!-- AUTHORITY RECORDS -->
+<server id="authorityserver"  listenref="authorityserver" >
+    <directory>__BASE_DIR__/zebradb/authorities</directory>
+    <config>__BASE_DIR__/etc/zebra-authorities.cfg</config>
+</server>
+<serverinfo id="authorityserver">
+    <ccl2rpn>__BASE_DIR__/etc/ccl.properties</ccl2rpn>
+    <user>__ZEBRA_USER__</user>
+    <password>__ZEBRA_PASS__</password>
+</serverinfo>
+
+<!-- ADDITIONAL KOHA CONFIGURATION DIRECTIVE -->
+<config>
+ <database>__MYSQL_DB__</database>
+ <hostname>__MYSQL_HOST__</hostname>
+ <user>__MYSQL_USER__</user>
+ <pass>__MYSQL_PASS__</pass>
+ <biblioserver>biblios</biblioserver>
+ <biblioservershadow>1</biblioservershadow>
+ <authorityserver>authorities</authorityserver>
+ <authorityservershadow>1</authorityservershadow>
+ <intranetdir>__BASE_DIR__/intranet/cgi-bin</intranetdir>
+ <opacdir>__BASE_DIR__/opac/cgi-bin</opacdir>
+ <opachtdocs>__BASE_DIR__/opac/htdocs/opac-tmpl</opachtdocs>
+ <intrahtdocs>__BASE_DIR__/intranet/htdocs/intranet-tmpl</intrahtdocs>
+ <includes>__BASE_DIR__/intranet/htdocs/intranet-tmpl/default/en/includes/</includes>
+</config>
+</yazgfs>
diff --git a/etc/koha-httpd.conf b/etc/koha-httpd.conf
new file mode 100644 (file)
index 0000000..78ed848
--- /dev/null
@@ -0,0 +1,59 @@
+# Koha Apache Configuration Directives
+
+#NameVirtualHost *
+
+## OPAC
+<VirtualHost __WEBSERVER_IP__:80>
+   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]
+</VirtualHost>
+
+## Intranet
+<VirtualHost __WEBSERVER_IP__:8080>
+   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]
+</VirtualHost>
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 (file)
index 0000000..fe88796
--- /dev/null
@@ -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 (file)
index 0000000..a70d510
--- /dev/null
@@ -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 (file)
index 0000000..9f92467
--- /dev/null
@@ -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
+# <grep -o '__.*__' etc/* | cut -f2 -d: | sort -u | sed -e 's/^/  "/;s/$/" => "",/'
+%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 = <INPUT>;
+  return $file;
+}
+
+__END__
+
+
+=head1 SEE ALSO
+
+Makefile.PL, ExtUtils::MakeMaker(3)
+
+=head1 AUTHOR
+
+MJ Ray mjr at phonecoop.coop
+
+=cut
+