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/<instance>/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 <m.de.rooy@rijksmuseum.nl>
Does not work in its current state. Needs a follow-up.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Tomas Cohen Arazi 2015-10-20 11:34:49 -03:00
parent 5153d04e41
commit 4a714313fe
4 changed files with 35 additions and 2 deletions

View File

@ -39,6 +39,7 @@
<arg><option>--adminuser</option> n</arg>
<arg><option>--enable-sru</option></arg>
<arg><option>--sru-port</option> port</arg>
<arg><option>--upload-path</option> directory</arg>
<arg><option>--help</option>|<option>-h</option></arg>
<arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg>
@ -167,6 +168,14 @@
</listitem>
</varlistentry>
<varlistentry>
<term><option>--upload-path</option></term>
<listitem>
<para>Specifiy a <option>directory</option> for storing the instance's uploaded files.
It defaults to <filename>/var/lib/koha/instance/uploads</filename>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--help</option>,<option>-h</option></term>
<listitem>

View File

@ -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/<instance>/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" != "" ] || \

View File

@ -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"

View File

@ -260,7 +260,7 @@ __END_SRU_PUBLICSERVER__
<authorityservershadow>1</authorityservershadow>
<pluginsdir>__PLUGINS_DIR__</pluginsdir>
<enable_plugins>0</enable_plugins>
<upload_path></upload_path>
<upload_path>__UPLOAD_PATH__</upload_path>
<intranetdir>/usr/share/koha/intranet/cgi-bin</intranetdir>
<opacdir>/usr/share/koha/opac/cgi-bin/opac</opacdir>
<opachtdocs>/usr/share/koha/opac/htdocs/opac-tmpl</opachtdocs>