[Koha-patches] [PATCH] Bug 10733: Follow-up - use koha-sites.conf

Tomas Cohen Arazi tomascohen at gmail.com
Thu Aug 15 15:24:27 CEST 2013


In order to respect the current schema, where configuration values are pondered
like this:

hardcoded < koha-sites.conf < koha-create option switches

I changed the patch a bit. I even changed MEMCACHED_NAMESPACE for MEMCACHED_PREFIX
that seems to fit better in the current schema.

Any feedback is welcome.
Regards
To+

Sponsored-by: Universidad Nacional de Cordoba
---
 debian/docs/koha-create.xml | 28 +++++++++++++++++++++++++---
 debian/scripts/koha-create  | 32 ++++++++++++++++++++++----------
 2 files changed, 47 insertions(+), 13 deletions(-)

diff --git a/debian/docs/koha-create.xml b/debian/docs/koha-create.xml
index 0781fd3..61cf588 100644
--- a/debian/docs/koha-create.xml
+++ b/debian/docs/koha-create.xml
@@ -31,7 +31,7 @@
       <arg><option>--biblio-idx</option> dom|grs1</arg>
       <arg><option>--use-memcached</option></arg>
       <arg><option>--memcached-servers</option> server:port</arg>
-      <arg><option>--memcached-namespace</option> koha_namespace</arg>
+      <arg><option>--memcached-prefix</option> namespace_prefix</arg>
       <arg><option>--defaultsql</option> /path/to/some.sql</arg>
       <arg><option>--configfile</option> /path/to/config</arg>
       <arg><option>--passwdfile</option> /path/to/passwd</arg>
@@ -143,9 +143,9 @@
     </varlistentry>
 
     <varlistentry>
-      <term><option>--memcached-namespace</option></term>
+      <term><option>--memcached-prefix</option></term>
       <listitem>
-        <para>Specifiy a memcached <option>namespace</option> for the created Koha instance. You usually leave this option alone to avoid namespace collisions. It defaults to <option>koha_instance</option>.</para>
+        <para>Specifiy a <option>namespace prefix</option> for memcached. You usually leave this option alone to avoid namespace collisions. It defaults to <option>koha_</option>.</para>
       </listitem>
     </varlistentry>
 
@@ -219,6 +219,28 @@
       </varlistentry>
 
       <varlistentry>
+        <term><option>USE_MEMCACHED</option></term>
+        <listitem>
+          <para>Valid values are <option>yes</option> and <option>no</option>. If not present koha-create will default to <option>no</option>. Also, this will be overriden by the <option>--use-memcached</option> switch.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>MEMCACHED_SERVERS</option></term>
+        <listitem>
+          <para>A comma-separated list of valid memcached servers. Usually in the form of <option>host:port</option>. If not present koha-create will default to <option>127.0.0.1:11211</option>. Also, this will be overriden by the arguments of the <option>--memcached-servers</option> switch.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>MEMCACHED_PREFIX</option></term>
+        <listitem>
+          <para>A prefix for all new Koha instances to use in memcached. If not present koha-create will default to <option>koha_</option>. Also, this will be overriden by the arguments of the <option>--memcached-prefix</option> switch.</para>
+        </listitem>
+      </varlistentry>
+
+
+      <varlistentry>
         <term><option>ZEBRA_MARC_FORMAT</option></term>
         <listitem>
           <para>Specifies format of MARC records to be indexed by Zebra.  Possible values are 'marc21', 'normarc' and 'unimarc'.</para>
diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create
index bcfadc9..d655ca2 100755
--- a/debian/scripts/koha-create
+++ b/debian/scripts/koha-create
@@ -23,6 +23,8 @@ usage="Usage: $0 [--create-db|--request-db|--populate-db|--use-db] \
     [--marcflavor marc21|normarc|unimarc] \
     [--zebralang en|es|fr|nb|ru|uk] \
     [--auth-idx dom|grs1] [--biblio-idx dom|grs1] \
+    [--use-memcached] \
+    [--memcached-servers server:port] [--memcached-prefix prefix] \
     [--defaultsql /path/to/some.sql] \
     [--configfile /path/to/config] [--passwdfile /path/to/passwd] \
     [--database database] [--adminuser n] instancename"
@@ -164,14 +166,20 @@ set_memcached()
     if [ "$CLO_MEMCACHED_SERVERS" != "" ]; then
         MEMCACHED_SERVERS=$CLO_MEMCACHED_SERVERS
     else
-        MEMCACHED_SERVERS=$DEFAULT_MEMCACHED_SERVERS
+        if [ "$MEMCACHED_SERVERS" = "" ]; then
+            MEMCACHED_SERVERS=$DEFAULT_MEMCACHED_SERVERS
+        # else: was set by the koha-sites.conf file
+        fi
     fi
 
-    if [ "$CLO_MEMCACHED_NAMESPACE" != "" ]; then
-        MEMCACHED_NAMESPACE=$CLO_MEMCACHED_NAMESPACE
+    if [ "$CLO_MEMCACHED_PREFIX" != "" ]; then
+        MEMCACHED_NAMESPACE="$CLO_MEMCACHED_PREFIX"_"$instance"
     else
-        # default
-        MEMCACHED_NAMESPACE="koha_$instance"
+        if [ "$MEMCACHED_PREFIX" != "" ]; then 
+            MEMCACHED_NAMESPACE="$MEMCACHED_PREFIX"_"$instance"
+        else
+            MEMCACHED_NAMESPACE="$DEFAULT_MEMCACHED_PREFIX"_"$instance"
+        fi
     fi
 
 }
@@ -189,10 +197,14 @@ ZEBRA_MARC_FORMAT="marc21"
 ZEBRA_LANGUAGE="en"
 ADMINUSER="1"
 PASSWDFILE="/etc/koha/passwd"
+
+# memcached variables
 USE_MEMCACHED="no"
 MEMCACHED_SERVERS=""
-MEMCACHED_NAMESPACE=""
+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"
@@ -210,7 +222,7 @@ fi
 
 [ $# -ge 2 ] && [ $# -le 16 ] || die $usage
 
-TEMP=`getopt -o crpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser:,memcached-servers:,memcached-namespace:, \
+TEMP=`getopt -o crpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,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!
@@ -224,7 +236,7 @@ CLO_ADMINUSER=""
 CLO_BIBLIOS_INDEXING_MODE=""
 CLO_AUTHORITIES_INDEXING_MODE=""
 CLO_MEMCACHED_SERVERS=""
-CLO_MEMCACHED_NAMESPACE=""
+CLO_MEMCACHED_PREFIX=""
 
 
 while true ; do
@@ -239,8 +251,8 @@ while true ; do
             --memcached-servers)
                 CLO_MEMCACHED_SERVERS="$2"
                 shift 2 ;;
-            --memcached-namespace)
-                CLO_MEMCACHED_NAMESPACE="$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 ;;
-- 
1.8.1.2



More information about the Koha-patches mailing list