X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=debian%2Fscripts%2Fkoha-create;h=841ef86143bc921589cae8ce4049b2c5e7ad1ecd;hb=d7a55f58901d7cfd98b846213654df0d7544695b;hp=b0c418c1bc487c40fab489ebc7b9104d0c1f9797;hpb=b1e2fa8fcaad4d8649e185fbcce2c7210bd8d40a;p=koha_fer diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index b0c418c1bc..841ef86143 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # koha-create -- Create a new Koha instance. # Copyright 2010 Catalyst IT, Ltd @@ -19,16 +19,56 @@ set -e -usage="Usage: $0 [--create-db|--request-db|--populate-db|--use-db] \ - [--marcflavor marc21|normarc|unimarc] \ - [--zebralang en|nb|fr] \ - [--defaultsql /path/to/some.sql] \ - [--configfile /path/to/config] [--passwdfile /path/to/passwd] \ - [--database database] [--adminuser n] instancename" - -die() { - echo "$@" 1>&2 +# include helper functions +if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then + . "/usr/share/koha/bin/koha-functions.sh" +else + echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 exit 1 +fi + +usage() +{ + local scriptname=$0 + cat < "$2" + } getmysqlhost() { @@ -74,6 +126,158 @@ getinstancemysqldatabase() { xmlstarlet sel -t -v 'yazgfs/config/database' "/etc/koha/sites/$1/koha-conf.xml" } +check_apache_config() +{ + + # Check that mpm_itk is installed and enabled + if ! /usr/sbin/apachectl -M 2> /dev/null | grep -q 'mpm_itk'; then + # Check Apache version + APACHE_DISABLE_MPM_MSG="" + if /usr/sbin/apache2ctl -v | grep -q "Server version: Apache/2.4"; then + # mpm_event or mpm_worker need to be disabled first. mpm_itk depends + # on mpm_prefork, which is enabled if needed. See + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=734865 + if /usr/sbin/apachectl -M 2> /dev/null | grep -q 'mpm_event'; then + APACHE_DISABLE_MPM_MSG=" sudo a2dismod mpm_event ;" + elif /usr/sbin/apachectl -M 2> /dev/null | grep -q 'mpm_worker'; then + APACHE_DISABLE_MPM_MSG=" sudo a2dismod mpm_worker ;" + # else mpm_prefork: a2enmod mpm_itk works + fi + # else Apache 2.2: a2enmod mpm_itk works + fi + + cat 1>&2 < /dev/null | grep -q 'rewrite_module'; then + cat 1>&2 < /dev/null | grep -q 'cgi_module'; then + cat 1>&2 << EOM +Koha requires mod_cgi to be enabled within Apache in order to run. +Typically this can be enabled with: + + sudo a2enmod cgi +EOM + die + fi + +} + +set_biblios_indexing_mode() +{ + local indexing_mode=$1 + local marc_format=$2 + + case $indexing_mode in + "dom") + START_BIBLIOS_RETRIEVAL_INFO=`cat <\n + \n + +EOF` + + END_BIBLIOS_RETRIEVAL_INFO=`cat <\n + <\/xi:fallback>\n + <\/xi:include> +EOF` + BIBLIOS_INDEXING_MODE="dom" + ZEBRA_BIBLIOS_CFG="zebra-biblios-dom.cfg" + ;; + "grs1") + START_BIBLIOS_RETRIEVAL_INFO=" " + END_BIBLIOS_RETRIEVAL_INFO=" <\/retrievalinfo>" + BIBLIOS_INDEXING_MODE="grs1" + ZEBRA_BIBLIOS_CFG="zebra-biblios.cfg" + ;; + *) + die "Error: '$indexing_mode' is not a valid indexing mode for bibliographic records." + ;; + esac +} + + +set_authorities_indexing_mode() +{ + local indexing_mode=$1 + local marc_format=$2 + + case $indexing_mode in + "dom") + START_AUTHORITIES_RETRIEVAL_INFO=`cat <\n + \n + +EOF` + + END_AUTHORITIES_RETRIEVAL_INFO=`cat <\n + <\/xi:fallback>\n + <\/xi:include>\n +EOF` + AUTHORITIES_INDEXING_MODE="dom" + ZEBRA_AUTHORITIES_CFG="zebra-authorities-dom.cfg" + ;; + "grs1") + START_AUTHORITIES_RETRIEVAL_INFO=" " + END_AUTHORITIES_RETRIEVAL_INFO=" <\/retrievalinfo>" + AUTHORITIES_INDEXING_MODE="grs1" + ZEBRA_AUTHORITIES_CFG="zebra-authorities.cfg" + ;; + *) + die "Error: '$indexing_mode' is not a valid indexing mode for authority records." + ;; + esac +} + + +set_memcached() +{ + local instance="$1" + + if [ "$CLO_MEMCACHED_SERVERS" != "" ]; then + MEMCACHED_SERVERS=$CLO_MEMCACHED_SERVERS + else + if [ "$MEMCACHED_SERVERS" = "" ]; then + MEMCACHED_SERVERS=$DEFAULT_MEMCACHED_SERVERS + # else: was set by the koha-sites.conf file + fi + fi + + if [ "$CLO_MEMCACHED_PREFIX" != "" ]; then + MEMCACHED_NAMESPACE="$CLO_MEMCACHED_PREFIX$instance" + else + if [ "$MEMCACHED_PREFIX" != "" ]; then + MEMCACHED_NAMESPACE="$MEMCACHED_PREFIX$instance" + else + MEMCACHED_NAMESPACE="$DEFAULT_MEMCACHED_PREFIX$instance" + fi + fi + +} + # Set defaults and read config file, if it exists. DOMAIN="" OPACPORT="80" @@ -87,14 +291,32 @@ ZEBRA_MARC_FORMAT="marc21" ZEBRA_LANGUAGE="en" ADMINUSER="1" PASSWDFILE="/etc/koha/passwd" + +# memcached variables +USE_MEMCACHED="no" +MEMCACHED_SERVERS="" +MEMCACHED_PREFIX="" +# hardcoded memcached defaults +DEFAULT_MEMCACHED_SERVERS="127.0.0.1:11211" +DEFAULT_MEMCACHED_PREFIX="koha_" + +# Indexing mode variables (default is DOM) +BIBLIOS_INDEXING_MODE="dom" +AUTHORITIES_INDEXING_MODE="dom" + +START_BIBLIOS_RETRIEVAL_INFO="" +END_BIBLIOS_RETRIEVAL_INFO="" +START_AUTHORITIES_RETRIEVAL_INFO="" +END_AUTHORITIES_RETRIEVAL_INFO="" + if [ -e /etc/koha/koha-sites.conf ] then . /etc/koha/koha-sites.conf fi -[ $# -ge 2 ] && [ $# -le 16 ] || die $usage +[ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" ) -TEMP=`getopt -o crpm:l:d:f:a: -l create-db,request-db,populate-db,use-db,marcflavor:,zebralang:,defaultsql:,configfile:,passwdfile:,adminuser: \ +TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser:,memcached-servers:,memcached-prefix:, \ -n "$0" -- "$@"` # Note the quotes around `$TEMP': they are essential! @@ -105,23 +327,53 @@ CLO_ZEBRA_MARC_FORMAT="" CLO_ZEBRA_LANGUAGE="" CLO_DEFAULTSQL="" CLO_ADMINUSER="" +CLO_BIBLIOS_INDEXING_MODE="" +CLO_AUTHORITIES_INDEXING_MODE="" +CLO_MEMCACHED_SERVERS="" +CLO_MEMCACHED_PREFIX="" + while true ; do - case "$1" in - -c|--create-db) op=create ; shift ;; - -r|--request-db) op=request ; shift ;; - -p|--populate-db) op=populate ; shift ;; - -u|--use-db) op=use ; shift ;; - -m|--marcflavor) CLO_ZEBRA_MARC_FORMAT="$2" ; shift 2 ;; - -l|--zebralang) CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;; - -d|--defaultsql) CLO_DEFAULTSQL="$2" ; shift 2 ;; - -f|--configfile) configfile="$2" ; shift 2 ;; - -s|--passwdfile) CLO_PASSWDFILE="$2" ; shift 2 ;; - -b|--database) CLO_DATABASE="$2" ; shift 2 ;; - -a|--adminuser) CLO_ADMINUSER="$2" ; shift 2 ;; - --) shift ; break ;; - *) die "Internal error processing command line arguments" ;; - esac + case "$1" in + -c|--create-db) + op=create ; shift ;; + -r|--request-db) + op=request ; shift ;; + -p|--populate-db) + op=populate ; shift ;; + -u|--use-db) + op=use ; shift ;; + --use-memcached) + USE_MEMCACHED="yes" ; shift ;; + --memcached-servers) + CLO_MEMCACHED_SERVERS="$2" ; shift 2 ;; + --memcached-prefix) + CLO_MEMCACHED_PREFIX="$2" ; shift 2;; + -m|--marcflavor) + CLO_ZEBRA_MARC_FORMAT="$2" ; shift 2 ;; + -l|--zebralang) + CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;; + --auth-idx) + CLO_AUTHORITIES_INDEXING_MODE="$2" ; shift 2 ;; + --biblio-idx) + CLO_BIBLIOS_INDEXING_MODE="$2" ; shift 2 ;; + -d|--defaultsql) + CLO_DEFAULTSQL="$2" ; shift 2 ;; + -f|--configfile) + configfile="$2" ; shift 2 ;; + -s|--passwdfile) + CLO_PASSWDFILE="$2" ; shift 2 ;; + -b|--database) + CLO_DATABASE="$2" ; shift 2 ;; + -a|--adminuser) + CLO_ADMINUSER="$2" ; shift 2 ;; + -h|--help) + usage ; exit 0 ;; + --) + shift ; break ;; + *) + die "Internal error processing command line arguments" ;; + esac done # Load the configfile given on the command line @@ -157,8 +409,51 @@ then PASSWDFILE="$CLO_PASSWDFILE" fi +if [ "$CLO_BIBLIOS_INDEXING_MODE" != "" ]; then + BIBLIOS_INDEXING_MODE=$CLO_BIBLIOS_INDEXING_MODE +fi + +set_biblios_indexing_mode $BIBLIOS_INDEXING_MODE $ZEBRA_MARC_FORMAT + + +if [ "$CLO_AUTHORITIES_INDEXING_MODE" != "" ]; then + AUTHORITIES_INDEXING_MODE=$CLO_AUTHORITIES_INDEXING_MODE +fi + +set_authorities_indexing_mode $AUTHORITIES_INDEXING_MODE $ZEBRA_MARC_FORMAT + name="$1" +if [ "$USE_MEMCACHED" = "yes" ]; then + set_memcached $name +elif [ "$CLO_MEMCACHED_SERVERS" != "" ] || \ + [ "$CLO_MEMCACHED_PREFIX" != "" ]; then + + MSG=`cat < /dev/null 2>&1 || + a2ensite "${name}.conf" > /dev/null 2>&1 + }; then + echo "Warning: problem enabling $name in Apache" >&2 + fi service apache2 restart # Start Zebra.