[Koha-patches] [PATCH] Bug 11404: Apache 2.4 expects the sites definition files use the sufix '.conf'
Tomas Cohen Arazi
tomascohen at gmail.com
Mon Dec 16 19:09:22 CET 2013
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 needed ".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
oha-start-zebra
They should all keep working. Can be tested "the easy way" too.
Then sign on the patch.
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.
Regards
To+
Edit: some old indentation error fixed.
Sponsored-by: Universidad Nacional de Cordoba
---
debian/scripts/koha-create | 15 ++++++++++-----
debian/scripts/koha-disable | 14 ++++++++++++--
debian/scripts/koha-dump | 9 +++++++--
debian/scripts/koha-enable | 14 ++++++++++++--
debian/scripts/koha-list | 7 ++++++-
debian/scripts/koha-remove | 10 ++++++++--
debian/scripts/koha-restart-zebra | 7 ++++++-
debian/scripts/koha-start-zebra | 7 ++++++-
debian/scripts/koha-stop-zebra | 7 ++++++-
9 files changed, 73 insertions(+), 17 deletions(-)
diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create
index 7f05eb0..cead3fd 100755
--- a/debian/scripts/koha-create
+++ b/debian/scripts/koha-create
@@ -257,11 +257,11 @@ while true ; do
CLO_MEMCACHED_PREFIX="$2" ; shift 2;;
-m|--marcflavor)
CLO_ZEBRA_MARC_FORMAT="$2" ; shift 2 ;;
- -l|--zebralang)
+ -l|--zebralang)
CLO_ZEBRA_LANGUAGE="$2" ; shift 2 ;;
- --auth-idx)
+ --auth-idx)
CLO_AUTHORITIES_INDEXING_MODE="$2" ; shift 2 ;;
- --biblio-idx)
+ --biblio-idx)
CLO_BIBLIOS_INDEXING_MODE="$2" ; shift 2 ;;
-d|--defaultsql)
CLO_DEFAULTSQL="$2" ; shift 2 ;;
@@ -437,8 +437,13 @@ eof
fi #`
# Generate and install Apache site-available file and log dir.
- generate_config_file apache-site.conf.in \
- "/etc/apache2/sites-available/$name"
+ if apache2ctl -v | grep -q "Server version: Apache/2.4"; then
+ generate_config_file apache-site.conf.in \
+ "/etc/apache2/sites-available/$name.conf"
+ else
+ generate_config_file apache-site.conf.in \
+ "/etc/apache2/sites-available/$name"
+ fi
mkdir "/var/log/koha/$name"
chown "$username:$username" "/var/log/koha/$name"
diff --git a/debian/scripts/koha-disable b/debian/scripts/koha-disable
index 75e3997..4eb0fbc 100755
--- a/debian/scripts/koha-disable
+++ b/debian/scripts/koha-disable
@@ -34,13 +34,18 @@ warn()
is_enabled()
{
local instancename=$1
+ local instancefile="/etc/apache2/sites-available/$instancename"
+
+ if apache2ctl -v | grep -q "Server version: Apache/2.4"; then
+ instancefile="$instancefile.conf"
+ fi
if ! is_instance $instancename; then
return 1
fi
if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
- "/etc/apache2/sites-available/$instancename" ; then
+ "$instancefile" ; then
return 1
else
return 0
@@ -63,10 +68,15 @@ is_instance()
disable_instance()
{
local instancename=$1
+ local instancefile="/etc/apache2/sites-available/$instancename"
+
+ if apache2ctl -v | grep -q "Server version: Apache/2.4"; then
+ instancefile="$instancefile.conf"
+ fi
if is_enabled $instancename; then
sed -i 's:^\s*#\(\s*Include /etc/koha/apache-shared-disable.conf\)$:\1:' \
- "/etc/apache2/sites-available/$instancename"
+ "$instancefile"
return 0
else
return 1
diff --git a/debian/scripts/koha-dump b/debian/scripts/koha-dump
index 2fe9edd..6bba350 100755
--- a/debian/scripts/koha-dump
+++ b/debian/scripts/koha-dump
@@ -54,14 +54,19 @@ mysqldump --databases --host="$mysqlhost" \
chown "root:$name-koha" "$dbdump"
chmod g+r "$dbdump"
+instancefile="$name"
+if apache2ctl -v | grep -q "Server version: Apache/2.4"; then
+ # Apache 2.4 needs the file have the sufix .conf
+ instancefile="$instancefile.conf"
+fi
# Dump configs, logs, etc.
metadump="$backupdir/$name-$date.tar.gz"
echo "* configs, logs to $metadump"
tar -C / -czf "$metadump" \
"etc/koha/sites/$name" \
- "etc/apache2/sites-available/$name" \
- "etc/apache2/sites-enabled/$name" \
+ "etc/apache2/sites-available/$instancefile" \
+ "etc/apache2/sites-enabled/$instancefile" \
"var/lib/koha/$name" \
"var/log/koha/$name"
diff --git a/debian/scripts/koha-enable b/debian/scripts/koha-enable
index c0bbfa2..43bedf2 100755
--- a/debian/scripts/koha-enable
+++ b/debian/scripts/koha-enable
@@ -34,13 +34,18 @@ warn()
is_enabled()
{
local instancename=$1
+ local instancefile="/etc/apache2/sites-available/$instancename"
+
+ if apache2ctl -v | grep -q "Server version: Apache/2.4"; then
+ instancefile="$instancefile.conf"
+ fi
if ! is_instance $instancename; then
return 1
fi
if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
- "/etc/apache2/sites-available/$instancename" ; then
+ "$instancefile" ; then
return 1
else
return 0
@@ -63,10 +68,15 @@ is_instance()
enable_instance()
{
local instancename=$1
+ local instancefile="/etc/apache2/sites-available/$instancename"
+
+ if apache2ctl -v | grep -q "Server version: Apache/2.4"; then
+ instancefile="$instancefile.conf"
+ fi
if ! is_enabled $instancename; then
sed -i 's:^\(\s*Include /etc/koha/apache-shared-disable.conf\)$:#\1:' \
- "/etc/apache2/sites-available/$instancename"
+ "$instancefile"
return 0
else
return 1
diff --git a/debian/scripts/koha-list b/debian/scripts/koha-list
index 445a22a..b4d016f 100755
--- a/debian/scripts/koha-list
+++ b/debian/scripts/koha-list
@@ -28,9 +28,14 @@ die()
is_enabled()
{
local instancename=$1
+ local instancefile="/etc/apache2/sites-available/$instancename"
+
+ if apache2ctl -v | grep -q "Server version: Apache/2.4"; then
+ instancefile="$instancefile.conf"
+ fi
if grep '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
- "/etc/apache2/sites-available/$instancename" > /dev/null
+ "$instancefile" > /dev/null
then
return 1
else
diff --git a/debian/scripts/koha-remove b/debian/scripts/koha-remove
index 3fa5ef1..1de3232 100755
--- a/debian/scripts/koha-remove
+++ b/debian/scripts/koha-remove
@@ -68,8 +68,14 @@ eof
# If the daemon is not running already, we don't want to fail this loop. So bin the result code if this fails.
koha-stop-zebra $name || /bin/true
- [ -f "/etc/apache2/sites-available/$name" ] && \
- rm "/etc/apache2/sites-available/$name"
+
+ instancefile="$name"
+ if apache2ctl -v | grep -q "Server version: Apache/2.4"; then
+ instancefile="$instancefile.conf"
+ fi
+
+ [ -f "/etc/apache2/sites-available/$instancefile" ] && \
+ rm "/etc/apache2/sites-available/$instancefile"
[ -f "/etc/koha/sites/$name/koha-conf.xml" ] && \
rm "/etc/koha/sites/$name/koha-conf.xml"
[ -f "/etc/koha/sites/$name/zebra-biblios.cfg" ] && \
diff --git a/debian/scripts/koha-restart-zebra b/debian/scripts/koha-restart-zebra
index 024251e..0ea9cfc 100755
--- a/debian/scripts/koha-restart-zebra
+++ b/debian/scripts/koha-restart-zebra
@@ -32,13 +32,18 @@ warn()
is_enabled()
{
local instancename=$1
+ local instancefile="/etc/apache2/sites-available/$instancename"
+
+ if apache2ctl -v | grep -q "Server version: Apache/2.4"; then
+ instancefile="$instancefile.conf"
+ fi
if ! is_instance $instancename; then
return 1
fi
if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
- "/etc/apache2/sites-available/$instancename" ; then
+ "$instancefile" ; then
return 1
else
return 0
diff --git a/debian/scripts/koha-start-zebra b/debian/scripts/koha-start-zebra
index f63ab42..dc771a0 100755
--- a/debian/scripts/koha-start-zebra
+++ b/debian/scripts/koha-start-zebra
@@ -32,13 +32,18 @@ warn()
is_enabled()
{
local instancename=$1
+ local instancefile="/etc/apache2/sites-available/$instancename"
+
+ if apache2ctl -v | grep -q "Server version: Apache/2.4"; then
+ instancefile="$instancefile.conf"
+ fi
if ! is_instance $instancename; then
return 1
fi
if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
- "/etc/apache2/sites-available/$instancename" ; then
+ "$instancefile" ; then
return 1
else
return 0
diff --git a/debian/scripts/koha-stop-zebra b/debian/scripts/koha-stop-zebra
index e60f2b3..8fff226 100755
--- a/debian/scripts/koha-stop-zebra
+++ b/debian/scripts/koha-stop-zebra
@@ -32,13 +32,18 @@ warn()
is_enabled()
{
local instancename=$1
+ local instancefile="/etc/apache2/sites-available/$instancename"
+
+ if apache2ctl -v | grep -q "Server version: Apache/2.4"; then
+ instancefile="$instancefile.conf"
+ fi
if ! is_instance $instancename; then
return 1
fi
if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
- "/etc/apache2/sites-available/$instancename" ; then
+ "$instancefile" ; then
return 1
else
return 0
--
1.8.5
More information about the Koha-patches
mailing list