Bug 20428: Add the option to specify a tmp uploads dir
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 29 Mar 2018 13:25:43 +0000 (10:25 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 14 May 2018 13:36:38 +0000 (10:36 -0300)
This patch adds an option to the koha-conf.xml file for specifying
a temporary uploaded files directory.

The koha-create script is adjusted to handle it and a convenient option
switch is added. If ommited, it will default to
/var/lib/koha/<instance>/uploads_tmp.

koha-create-dirs is patched to create the required directory with the
right permissions.

The docs get the new parameter documented.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

debian/docs/koha-create.xml
debian/scripts/koha-create
debian/scripts/koha-create-dirs
debian/templates/koha-conf-site.xml.in
etc/koha-conf.xml

index 77a3e7d..07c1052 100644 (file)
@@ -42,6 +42,7 @@
       <arg><option>--template-cache-dir</option> directory</arg>
       <arg><option>--timezone</option> time/zone</arg>
       <arg><option>--upload-path</option> directory</arg>
+      <arg><option>--upload-tmp-path</option> directory</arg>
       <arg><option>--letsencrypt</option></arg>
       <arg><option>--help</option>|<option>-h</option></arg>
 
     </varlistentry>
 
     <varlistentry>
+      <term><option>--upload-tmp-path</option></term>
+      <listitem>
+        <para>Specify a <option>directory</option> for storing the temporarily uploaded files of the instance.
+              It defaults to <filename>/var/lib/koha/instance/uploads_tmp</filename>.</para>
+      </listitem>
+    </varlistentry>
+
+    <varlistentry>
       <term><option>--letsencrypt</option></term>
       <listitem>
         <para>Set up a https-only website with letsencrypt certificates</para>
index 65d62bd..88232eb 100755 (executable)
@@ -74,6 +74,8 @@ Options:
   --timezone time/zone      Specify a timezone. e.g. America/Argentina
   --upload-path dir         Set a user defined upload_path. It defaults to
                             /var/lib/koha/<instance>/uploads
+  --upload-tmp-path dir     Set a user defined upload_tmp_path. It defaults to
+                            /var/lib/koha/<instance>/uploads_tmp
   --letsencrypt             Set up a https-only site with letsencrypt certificates
   --help,-h                 Show this help.
 
@@ -118,6 +120,7 @@ generate_config_file() {
         -e "s#__TEMPLATE_CACHE_DIR__#$TEMPLATE_CACHE_DIR#g" \
         -e "s#__TIMEZONE__#$TIMEZONE#g" \
         -e "s#__UPLOAD_PATH__#$UPLOAD_PATH#g" \
+        -e "s#__UPLOAD_TMP_PATH__#$UPLOAD_TMP_PATH#g" \
         -e "s/__LOG_DIR__/\/var\/log\/koha\/$name/g" \
         -e "s/__PLUGINS_DIR__/\/var\/lib\/koha\/$name\/plugins/g" \
         -e "s/__MEMCACHED_NAMESPACE__/$MEMCACHED_NAMESPACE/g" \
@@ -329,6 +332,17 @@ set_upload_path()
     fi
 }
 
+set_upload_tmp_path()
+{
+    local instance="$1"
+
+    if [ "$CLO_UPLOAD_TMP_PATH" != "" ]; then
+        UPLOAD_TMP_PATH=$CLO_UPLOAD_TMP_PATH
+    else
+        UPLOAD_TMP_PATH="$UPLOAD_PATH_BASE/$instance/$UPLOAD_TMP_DIR"
+    fi
+}
+
 enable_sru_server()
 {
     # remove the commenting symbols
@@ -417,6 +431,9 @@ UPLOAD_DIR="uploads"
 UPLOAD_PATH=""
 # timezone defaults to empty
 TIMEZONE=""
+# hardcoded upload_tmp_path
+UPLOAD_TMP_DIR="uploads_tmp"
+UPLOAD_TMP_PATH=""
 # cache base dir
 CACHE_DIR_BASE="/var/cache/koha"
 # Generate a randomizaed API secret
@@ -463,6 +480,7 @@ CLO_AUTHORITIES_INDEXING_MODE=""
 CLO_MEMCACHED_SERVERS=""
 CLO_MEMCACHED_PREFIX=""
 CLO_UPLOAD_PATH=""
+CLO_UPLOAD_TMP_PATH=""
 CLO_LETSENCRYPT=""
 CLO_TEMPLATE_CACHE_DIR=""
 CLO_TIMEZONE=""
@@ -511,6 +529,8 @@ while true ; do
             CLO_TIMEZONE="$2" ; shift 2 ;;
         --upload-path)
             CLO_UPLOAD_PATH="$2" ; shift 2 ;;
+        --upload-tmp-path)
+            CLO_UPLOAD_TMP_PATH="$2" ; shift 2 ;;
         --letsencrypt)
             CLO_LETSENCRYPT="yes" ; shift ;;
         -h|--help)
@@ -580,6 +600,7 @@ set_authorities_indexing_mode $AUTHORITIES_INDEXING_MODE $ZEBRA_MARC_FORMAT
 name="$1"
 
 set_upload_path $name
+set_upload_tmp_path $name
 
 if [ "$op" = use ] && [ "$CLO_DATABASE" = "" ] &&
    ( [ ! -f "$PASSWDFILE" ] || [ ! `cat $PASSWDFILE | grep "^$name:"` ] )
index 6d47c15..f7777df 100755 (executable)
@@ -55,6 +55,7 @@ do
     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/lib/koha/$name/uploads_tmp"
     userdir "$name" "/var/lock/koha/$name"
     userdir "$name" "/var/lock/koha/$name/authorities"
     userdir "$name" "/var/lock/koha/$name/biblios"
index 6d3d31e..7d91711 100644 (file)
@@ -261,6 +261,7 @@ __END_SRU_PUBLICSERVER__
  <pluginsdir>__PLUGINS_DIR__</pluginsdir> <!-- This entry can be repeated to use multiple directories -->
  <enable_plugins>0</enable_plugins>
  <upload_path>__UPLOAD_PATH__</upload_path>
+ <upload_tmp_path>__UPLOAD_TMP_PATH__</upload_tmp_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>
index 1b50f77..111c40f 100644 (file)
@@ -93,6 +93,7 @@ __PAZPAR2_TOGGLE_XML_POST__
  <pluginsdir>__PLUGINS_DIR__</pluginsdir> <!-- This entry can be repeated to use multiple directories -->
  <enable_plugins>0</enable_plugins>
  <upload_path></upload_path>
+ <upload_tmp_path></upload_tmp_path>
  <intranetdir>__INTRANET_CGI_DIR__</intranetdir>
  <opacdir>__OPAC_CGI_DIR__/opac</opacdir>
  <opachtdocs>__OPAC_TMPL_DIR__</opachtdocs>