From 647458098381de3d9cf67b6f3c8356367858ffc8 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Tue, 10 Nov 2015 15:41:28 +0000
Subject: [PATCH] OPENDJ-2177 Set man path in native packages

---
 opendj-packages/opendj-deb/resources/control/postinst     |   26 +++++++++++++++++++-------
 opendj-packages/opendj-rpm/resources/specs/postinstall.sh |    8 ++++++++
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/opendj-packages/opendj-deb/resources/control/postinst b/opendj-packages/opendj-deb/resources/control/postinst
index 9b023d8..305c4bb 100644
--- a/opendj-packages/opendj-deb/resources/control/postinst
+++ b/opendj-packages/opendj-deb/resources/control/postinst
@@ -24,7 +24,6 @@
 #      Copyright 2013-2015 ForgeRock AS.
 #
 
-set -e
 # Post install script
 # Install is launched with an empty second arg.
 # If the package is already installed, the second arg. is not empty.
@@ -42,11 +41,6 @@
         echo *Starting upgrade...
         ${deb.prefix}/./upgrade -n --acceptLicense
         echo
-        if [ "$?" -eq 2 ] ; then
-            # Upgrade fails - Requires mandatory user interaction.
-            # Nevertheless, exits successfully of the pkg process.
-            exit 0
-        fi
 
         if [ "$?" -eq 0 ] ; then
             # Restarts the service if needed.
@@ -57,13 +51,31 @@
                 echo
                 echo "*Restarting server..."
                 ${deb.prefix}/./bin/start-ds
-                rm -f ${deb.prefix}/logs/status
+                if [ "$?" -eq 0 ] ; then
+                    rm -f ${deb.prefix}/logs/status
+                else
+                    echo "start-ds failed with return code $?. Please read ${deb.prefix}/logs/status for more details."
+                fi
             fi
+        else
+            # Upgrade fails - Requires mandatory user interaction.
+            # Nevertheless, exits successfully of the pkg process.
+            echo "upgrade failed with return code $?. Please read the installation guide for more information on the upgrade process."
+            exit 0
         fi
     else
         echo "Invalid installation, could not find the build info file."
         exit -1
     fi
 fi
+
+
+# Add OpenDJ man pages to MANPATH
+MAN_CONFIG_FILE=/etc/manpath.config
+MANPATH_DIRECTIVE=MANDATORY_MANPATH
+grep -q "$MANPATH_DIRECTIVE.*opendj" $MAN_CONFIG_FILE 2> /dev/null
+if [ $? -ne 0 ]; then
+    echo "$MANPATH_DIRECTIVE ${deb.prefix}/share/man" >> $MAN_CONFIG_FILE
+fi
 # End post install script
 echo
diff --git a/opendj-packages/opendj-rpm/resources/specs/postinstall.sh b/opendj-packages/opendj-rpm/resources/specs/postinstall.sh
index f82be5f..fd4f2ea 100644
--- a/opendj-packages/opendj-rpm/resources/specs/postinstall.sh
+++ b/opendj-packages/opendj-rpm/resources/specs/postinstall.sh
@@ -63,3 +63,11 @@
     fi
     fi
 fi
+
+# Add OpenDJ man pages to MANPATH
+MAN_CONFIG_FILE=/etc/man.config
+MANPATH_DIRECTIVE=MANPATH
+grep -q "$MANPATH_DIRECTIVE.*opendj" $MAN_CONFIG_FILE 2> /dev/null
+if [ $? -ne 0 ]; then
+    echo "$MANPATH_DIRECTIVE %{_prefix}/share/man" >> $MAN_CONFIG_FILE
+fi

--
Gitblit v1.10.0