From 4a714313fef3f1a5076cf94c4e0e4e484e4c2299 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 20 Oct 2015 11:34:49 -0300 Subject: [PATCH] Bug 14674: koha-create should populate upload_path This patch makes koha-create and koha-create-dirs aware of the new upload_path configuration entry. It defaults to /var/lib/koha//uploads as proposed by Robin but lets the user specify its own directory, using the --upload-path option switch that is added by this patch. koha-create-dirs is tweaked so it also creates this new directory. The docs are updated accordingly. To test: - Apply the patch, have a packages setup (either by grabbing the relevant files [1] or by creating your own package). - Run koha-create --create-db instance => SUCCESS: /var/lib/koha/instance/uploads directory is created => SUCCESS: /etc/koha/sites/instance/koha-config.xml has upload_path set correctly - Create a new instance using the --upload-path making it point to whatever you want => SUCCESS: koha-conf.xml points to your chosen path - Sign off :-D Regards Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Marcel de Rooy Does not work in its current state. Needs a follow-up. Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- debian/docs/koha-create.xml | 9 +++++++++ debian/scripts/koha-create | 25 ++++++++++++++++++++++++- debian/scripts/koha-create-dirs | 1 + debian/templates/koha-conf-site.xml.in | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/debian/docs/koha-create.xml b/debian/docs/koha-create.xml index 4ae1b7c9da..129de9dcfb 100644 --- a/debian/docs/koha-create.xml +++ b/debian/docs/koha-create.xml @@ -39,6 +39,7 @@ n port + directory | instancename @@ -167,6 +168,14 @@ + + + + Specifiy a for storing the instance's uploaded files. + It defaults to /var/lib/koha/instance/uploads. + + + , diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index 375707c103..dd32e27c1e 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -69,6 +69,8 @@ Options: --database dbname Enforce the use of the specified DB name (64 char limit) --adminuser n Explicit the admin user ID in the DB. Relevant in conjunction with --defaultsql and --populate-db. + --upload-path dir Set a user defined upload_path. It defaults to + /var/lib/koha//uploads --help,-h Show this help. Note: the instance name cannot be longer that 11 chars. @@ -107,6 +109,7 @@ generate_config_file() { -e "s/__DB_PASS__/$mysqlpwd/g" \ -e "s/__UNIXUSER__/$username/g" \ -e "s/__UNIXGROUP__/$username/g" \ + -e "s/__UPLOAD_PATH__/$UPLOAD_PATH/g" \ -e "s/__PLUGINS_DIR__/\/var\/lib\/koha\/$name\/plugins/g" \ -e "s/__MEMCACHED_NAMESPACE__/$MEMCACHED_NAMESPACE/g" \ -e "s/__MEMCACHED_SERVERS__/$MEMCACHED_SERVERS/g" \ @@ -286,6 +289,17 @@ set_memcached() } +set_upload_path() +{ + local $instance="$1" + + if [ "$CLO_UPLOAD_PATH" != "" ]; then + UPLOAD_PATH=$CLO_UPLOAD_PATH + else + UPLOAD_PATH="$UPLOAD_PATH_BASE/$instance/$UPLOAD_DIR" + fi +} + enable_sru_server() { # remove the commenting symbols @@ -318,6 +332,10 @@ MEMCACHED_PREFIX="" # hardcoded memcached defaults DEFAULT_MEMCACHED_SERVERS="127.0.0.1:11211" DEFAULT_MEMCACHED_PREFIX="koha_" +# hardcoded upload_path +UPLOAD_PATH_BASE="/var/lib/koha" +UPLOAD_DIR="uploads" +UPLOAD_PATH="" # SRU server variables ENABLE_SRU="no" @@ -343,7 +361,7 @@ fi [ $# -ge 1 ] && [ $# -le 16 ] || ( usage ; die "Error: wrong parameters" ) -TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,enable-sru,sru-port:,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser:,memcached-servers:,memcached-prefix:, \ +TEMP=`getopt -o chrpm:l:d:f:b:a: -l create-db,request-db,populate-db,use-db,use-memcached,enable-sru,sru-port:,help,marcflavor:,auth-idx:,biblio-idx:,zebralang:,defaultsql:,configfile:,passwdfile:,database:,adminuser:,memcached-servers:,memcached-prefix:,upload-path:, \ -n "$0" -- "$@"` # Note the quotes around `$TEMP': they are essential! @@ -358,6 +376,7 @@ CLO_BIBLIOS_INDEXING_MODE="" CLO_AUTHORITIES_INDEXING_MODE="" CLO_MEMCACHED_SERVERS="" CLO_MEMCACHED_PREFIX="" +CLO_UPLOAD_PATH="" while true ; do @@ -398,6 +417,8 @@ while true ; do ENABLE_SRU="yes" ; shift ;; --sru-port) SRU_SERVER_PORT="$2" ; shift 2 ;; + --upload-path) + CLO_UPLOAD_PATH="$2" ; shift 2 ;; -h|--help) usage ; exit 0 ;; --) @@ -458,6 +479,8 @@ set_authorities_indexing_mode $AUTHORITIES_INDEXING_MODE $ZEBRA_MARC_FORMAT name="$1" +set_upload_path $name + if [ "$USE_MEMCACHED" = "yes" ]; then set_memcached $name elif [ "$CLO_MEMCACHED_SERVERS" != "" ] || \ diff --git a/debian/scripts/koha-create-dirs b/debian/scripts/koha-create-dirs index 52e21340e4..dae0d48d68 100755 --- a/debian/scripts/koha-create-dirs +++ b/debian/scripts/koha-create-dirs @@ -52,6 +52,7 @@ do userdir "$name" "/var/lib/koha/$name/biblios/shadow" userdir "$name" "/var/lib/koha/$name/biblios/tmp" userdir "$name" "/var/lib/koha/$name/plugins" + userdir "$name" "/var/lib/koha/$name/uploads" userdir "$name" "/var/lock/koha/$name" userdir "$name" "/var/lock/koha/$name/authorities" userdir "$name" "/var/lock/koha/$name/biblios" diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in index d5ed5aa893..904a7e4014 100644 --- a/debian/templates/koha-conf-site.xml.in +++ b/debian/templates/koha-conf-site.xml.in @@ -260,7 +260,7 @@ __END_SRU_PUBLICSERVER__ 1 __PLUGINS_DIR__ 0 - + __UPLOAD_PATH__ /usr/share/koha/intranet/cgi-bin /usr/share/koha/opac/cgi-bin/opac /usr/share/koha/opac/htdocs/opac-tmpl -- 2.39.5