Bug 11404: Make the install process aware of the changes
authorTomas Cohen Arazi <tomascohen@gmail.com>
Tue, 6 May 2014 18:13:19 +0000 (15:13 -0300)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 19 May 2014 21:50:54 +0000 (21:50 +0000)
This patch makes the install scripts take care of the new file
and prompt for user confirmation on the apache file renaming step.

Both prompt and the renaming actions depend on the fact that there
are instances with their files missing the .conf appendix.

Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
debian/koha-common.config
debian/koha-common.install
debian/koha-common.postinst
debian/koha-common.templates

index 3f97df9..0504da2 100755 (executable)
@@ -42,5 +42,7 @@ fi
 
 db_input medium koha-common/automatically-update-translations || true
 
+db_input high koha-common/rename-apache-vhost-files || true
+
 db_go || true
 
index e215bde..90a06d9 100644 (file)
@@ -7,6 +7,7 @@ debian/koha-post-install-setup              usr/sbin
 debian/unavailable.html                     usr/share/koha/intranet/htdocs
 debian/unavailable.html                     usr/share/koha/opac/htdocs
 debian/templates/*                          etc/koha
+debian/scripts/koha-functions.sh            usr/share/koha/bin
 debian/scripts/koha-create                  usr/sbin
 debian/scripts/koha-create-dirs             usr/sbin
 debian/scripts/koha-disable                 usr/sbin
index f22bcb0..1912659 100644 (file)
@@ -78,6 +78,55 @@ EOF
     fi
 fi
 
+# Check if we need to rename the Apache vhost files
+RENAME_APACHE_FILES="no"
+for vhost in $(koha-list); do
+    if [ -f "/etc/apache2/sites-available/$vhost" ] && \
+       [ ! -f "/etc/apache2/sites-available/$vhost.conf" ]; then
+       RENAME_APACHE_FILES="yes"
+       break # at least one, trigger renaming
+    fi
+done
+
+if [ "$RENAME_APACHE_FILES" = "yes" ]; then
+    # If the user agreed we now rename their Apache files
+    db_get koha-common/rename-apache-vhost-files
+    if [ "$RET" = "false" ]; then
+        # We're not renaming the files, just print a warning
+        cat <<EOF >&2
+Warning: you have chosen not to migrate your Apache virtual hosts files to the
+Apache 2.4 naming schema. You can do it manually by running this for each
+Koha instance:
+
+    $ sudo a2dissite instance
+    $ sudo mv /etc/apache2/sites-available/instance \
+              /etc/apache2/sites-available/instance.conf
+    $ sudo a2ensite instance
+EOF
+    else
+        # We have to rename the Apache files
+        for site in $(koha-list); do
+            ENABLE_VHOST="yes"
+            if [ -f "/etc/apache2/sites-available/$site" ] && \
+               [ ! -f "/etc/apache2/sites-available/$site.conf" ]; then
+                if ! a2dissite $site > /dev/null 2>&1; then
+                    echo "Warning: problem disabling $site in Apache" >&2
+                    ENABLE_VHOST="no"
+                fi
+                # Rename the vhost definition files
+                mv "/etc/apache2/sites-available/$site" \
+                   "/etc/apache2/sites-available/$site.conf"
+
+                if [ "$ENABLE_VHOST" = "yes" ]; then
+                    if ! a2ensite $site > /dev/null 2>&1; then
+                        echo "Warning: problem enabling $site in Apache" >&2
+                    fi
+                fi
+            fi
+        done
+    fi
+fi
+
 db_stop
 
 exit 0
index 5576fe8..a6e86d2 100644 (file)
@@ -15,3 +15,11 @@ Default: true
 Description: automatically update translations
   When Koha is upgraded, any existing translated templates can be regenerated
   to keep everything in sync. Select "yes" if you want this.
+
+Template: koha-common/rename-apache-vhost-files
+Type: boolean
+Default: true
+Description: Rename the Apache virtual hosts files for Koha instances?
+ When Koha is upgraded, the Apache's virtual host definition files can be
+ renamed to match the needs of the newer Apache 2.4. Previously defined
+ Koha instances will get their Apache files appended '.conf'.