Koha/debian/scripts/koha-create-dirs
Tomas Cohen Arazi 06a1f18a1b Bug 17951: Make koha-create set template_cache_dir correctly
This patch makes koha-create (and friends) handle the template_cache_dir
config entry correctly.

It does so by:
- Adding a replaceable string to the template for koha-conf.xml
- Making koha-create-dirs create the needed directories (i.e.
 /var/cache/koha/instance and /var/cache/koha/instance/templates)
- Adding a --template-cache-dir switch to koha-create (so sysadmins can
  specify their favourite directory for the templates cache).
- koha-remove now takes care of the instance's *templates* dir.
- The install scripts now automatically create /var/cache/koha so it can
  be used later by koha-create and friends. It does so the same way it does
  for other install-created directories.

To test, you should ideally be able to build your own packages. This
instructions can be followed by people that doesn't have that ability
yet. But can be used on a custom packages setup too.

To test:
- Make sure you have the latest misc4dev in your kohadevbox (if it is a
  fresh box you have it already)
- Run:
  $ sudo perl misc4dev/cp_debian_files.pl
- Manually create the /var/cache/koha dir (skip if you have your own
        packages):
  $ sudo mkdir /var/cache/koha
- Create a new instance:
  $ sudo koha-create --create-db cachetest
=> SUCCESS:
    * /etc/koha/sites/cachetest/koha-conf.xml contains
    template_cache_dir and is populated with /var/cache/koha/cachetest/templates
    * The directory /var/cache/koha/cachetest/templates exists!
- Create a new instance, pass your own cache dir:
  $ sudo koha-create --create-db --template-cache-dir /tmp cachetest2
=> SUCCESS: etc/koha/sites/cachetest2/koha-conf.xml contains template_cache_dir
   and is populated with /tmp
- Run:
  $ man koha-create
=> SUCCESS: The docs mention the --template-cache-dir option switch
    correctly.
- Sign off :-D!

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

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-12-22 13:15:39 -03:00

65 lines
2.2 KiB
Bash
Executable file

#!/bin/sh
#
# koha-create-dirs -- Create dirs for a Koha instance.
# Copyright 2010 Catalyst IT, Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
userdir() {
local username="$1-koha"
local directory="$2"
if [ ! -d "$directory" ]
then
install -d -o "$username" -g "$username" "$directory"
fi
}
rootdir() {
local directory="$1"
if [ ! -d "$directory" ]
then
install -d -o root -g root "$directory"
fi
}
for name in "$@"
do
rootdir "/var/spool/koha/$name"
userdir "$name" "/etc/koha/sites/$name"
userdir "$name" "/var/cache/koha/$name"
userdir "$name" "/var/cache/koha/$name/templates"
userdir "$name" "/var/lib/koha/$name"
userdir "$name" "/var/lib/koha/$name/authorities"
userdir "$name" "/var/lib/koha/$name/authorities/key"
userdir "$name" "/var/lib/koha/$name/authorities/register"
userdir "$name" "/var/lib/koha/$name/authorities/shadow"
userdir "$name" "/var/lib/koha/$name/authorities/tmp"
userdir "$name" "/var/lib/koha/$name/biblios"
userdir "$name" "/var/lib/koha/$name/biblios/key"
userdir "$name" "/var/lib/koha/$name/biblios/register"
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"
userdir "$name" "/var/run/koha/$name"
userdir "$name" "/var/run/koha/$name/authorities"
userdir "$name" "/var/run/koha/$name/biblios"
done