From 6418cde51c219134b949b5c6cf23534106ed1204 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 6 Mar 2015 08:31:55 -0500
Subject: [PATCH] Simplified environment setup after .deb installation - Use a
 profile.d script instead of meddling with /etc/profile directly.

---
 packages/DEBIAN/postinst | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/packages/DEBIAN/postinst b/packages/DEBIAN/postinst
index 4f751327647..3b51f88de42 100644
--- a/packages/DEBIAN/postinst
+++ b/packages/DEBIAN/postinst
@@ -3,21 +3,11 @@
 # Script for installing VuFind 2.x on Ubuntu
 # This does not include the OCI8 libraries
 
-# Update the profile file to set required environment variables (unless they are
-# already defined there):
-grep -q JAVA_HOME= /etc/profile
-if [ $? -ne 0 ]; then
-    sh -c 'echo export JAVA_HOME=\"/usr/lib/jvm/default-java\" >> /etc/profile'
-fi
-grep -q VUFIND_HOME= /etc/profile
-if [ $? -ne 0 ]; then
-    sh -c 'echo export VUFIND_HOME=\"/usr/local/vufind2\"  >> /etc/profile'
-fi
-grep -q VUFIND_LOCAL_DIR= /etc/profile
-if [ $? -ne 0 ]; then
-    sh -c 'echo export VUFIND_LOCAL_DIR=\"\$VUFIND_HOME/local\"  >> /etc/profile'
-fi
-source /etc/profile
+# Update the profile file to set required environment variables:
+sh -c 'echo export JAVA_HOME=\"/usr/lib/jvm/default-java\" > /etc/profile.d/vufind.sh'
+sh -c 'echo export VUFIND_HOME=\"/usr/local/vufind2\"  >> /etc/profile.d/vufind.sh'
+sh -c 'echo export VUFIND_LOCAL_DIR=\"\$VUFIND_HOME/local\"  >> /etc/profile.d/vufind.sh'
+source /etc/profile.d/vufind.sh
 
 # Turn on mod_rewrite in Apache.
 a2enmod rewrite
-- 
GitLab