From 624c953b354a21f556ed499726d233dead6aa40f Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 6 May 2014 15:13:19 -0300 Subject: [PATCH] Bug 11404: Make the install process aware of the changes 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 Signed-off-by: Galen Charlton --- debian/koha-common.config | 2 ++ debian/koha-common.install | 1 + debian/koha-common.postinst | 49 ++++++++++++++++++++++++++++++++++++ debian/koha-common.templates | 8 ++++++ 4 files changed, 60 insertions(+) diff --git a/debian/koha-common.config b/debian/koha-common.config index 3f97df9b4f..0504da2fa9 100755 --- a/debian/koha-common.config +++ b/debian/koha-common.config @@ -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 diff --git a/debian/koha-common.install b/debian/koha-common.install index e215bde4e4..90a06d9885 100644 --- a/debian/koha-common.install +++ b/debian/koha-common.install @@ -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 diff --git a/debian/koha-common.postinst b/debian/koha-common.postinst index f22bcb0a02..1912659942 100644 --- a/debian/koha-common.postinst +++ b/debian/koha-common.postinst @@ -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 <&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 diff --git a/debian/koha-common.templates b/debian/koha-common.templates index 5576fe8a1c..a6e86d2102 100644 --- a/debian/koha-common.templates +++ b/debian/koha-common.templates @@ -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'. -- 2.39.5