Koha/debian/scripts/koha-disable
Tomas Cohen Arazi 7ec644da06 Bug 11404: add support for Apache 2.4's config file convention
Apache 2.4 expects the sites definition files use the sufix '.conf'

To reproduce:
- Install the 'koha-common' package on Debian 7 or Ubuntu 13.10+
  (both known to include Apache 2.4).
- Create an instance (for example testlibrary) using the supplied
  commands:
 $ koha-create --create-db testlibrary
> FAIL: apache reports an error like this:
"ERROR: Site testlibrary does not exist!"

This patch adds a test on the Apache version and appends the ".conf"
sufix if needed.

To test:

1st step: koha-create gets fixed:

-- The hard way --
- Apply the patch, and build the koha-common package on top of this
  commit.
- Install the built package on an Apache 2.4 Debian-based distro (Debian 7
  or Ubuntu 13.10 will work)
- Create a test instance:
 $ koha-create --create-db testlibrary
> SUCCESS: no more apache sites related error.

-- The easy way --
- Apply the patch, and copy the koha-create into an Apache 2.4
  Debian-based distro
- Create a test instance using the koha-create script you just
  copied:
 $ ./koha-create --create-db testlibrary
> SUCCESS: no more apache sites related error.

2nd step: the rest of the touched scripts keep working as usual

koha-disable
koha-dump
koha-enable
koha-list
koha-remove
koha-restart-zebra
koha-stop-zebra
koha-start-zebra

They should all keep working. Can be tested "the easy way" too.

Note: there might be another issues regarding Apache 2.4 deployments
like the need for

 $ a2enmod access_compat

and perhaps some directory permissions tweak, which I think should be
properly documented on the install instructions.

Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2014-05-19 21:47:03 +00:00

111 lines
2.2 KiB
Bash
Executable file

#!/bin/sh
#
# koha-disable - disable Koha instances.
# 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
die()
{
echo "$@" 1>&2
exit 1
}
warn()
{
echo "$@" 1>&2
}
is_enabled()
{
local instancename=$1
local instancefile="/etc/apache2/sites-available/$instancename.conf"
if ! is_instance $instancename; then
return 1
fi
if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
"$instancefile" ; then
return 1
else
return 0
fi
}
is_instance()
{
local instancename=$1
if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
-type d -printf '%f\n'\
| grep -q -x $instancename ; then
return 0
else
return 1
fi
}
disable_instance()
{
local instancename=$1
local instancefile="/etc/apache2/sites-available/$instancename.conf"
if is_enabled $instancename; then
sed -i 's:^\s*#\(\s*Include /etc/koha/apache-shared-disable.conf\)$:\1:' \
"$instancefile"
return 0
else
return 1
fi
}
usage()
{
local scriptname=$0
cat <<EOF
Disables Koha instances.
Usage: $scriptname instancename1 instancename2...
EOF
}
# Parse command line.
[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
restart_apache="no"
for name in "$@"
do
if is_instance $name ; then
if disable_instance $name; then
restart_apache="yes"
else
warn "Instance $name already disabled."
fi
else
warn "Unknown instance $name."
fi
done
if [ "$restart_apache" = "yes" ]; then
/etc/init.d/apache2 restart
fi
exit 0