From 4571675a785cf27b01455331d41629d0aa0c4c6d Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Thu, 16 May 2013 13:14:41 +0000
Subject: [PATCH] OPENDJ-904 RPM/Deb packages should not restart server after package update. - Modified RPM/Deb scripts - Modify RPM build number.

---
 opends/resource/debian/control/postinst |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/opends/resource/debian/control/postinst b/opends/resource/debian/control/postinst
index 3509f46..29aceda 100644
--- a/opends/resource/debian/control/postinst
+++ b/opends/resource/debian/control/postinst
@@ -1,6 +1,42 @@
-#!/bin/sh
+#!/bin/bash
 set -e
 # Post install script
-# Insert your post installation code here.
+# Install is launched with an empty second arg.
+# If the package is already installed, 
+#  the second arg. is not empty.
+# In this case, we are in upgrade mode.
+if [ "$1" = "configure" ] && [ ! -z "$2" ]
+then
+# For being secure, we check the buildinfo file too.
+  if [ -f @prefix@/config/buildinfo ]
+  then
+    echo *Starting upgrade...
+    @prefix@/./upgrade -n
+    echo
+# Upgrade fails - Requires mandatory user interaction.
+    if [ "$?" -eq 2 ]
+    then
+      exit 0 
+    fi
+# Restart the service if needed.
+# If server is stopped by upgrade process, the server will restart after upgrade.
+# If server is stopped before the upgrade process 
+#  (eg. upgrade the new package), the server will not restart.
+# Uses the flag for determining server status at this point.
+    if [ "$?" -eq 0 ]
+    then
+      if [ -f @prefix@/logs/status ]
+      then
+        echo
+        echo "*Restarting server..."        
+        @prefix@/./bin/start-ds
+        rm -f @prefix@/logs/status
+      fi   
+    fi
+  else 
+# Invalid installation, could not find the buildinfo file.
+    exit 0  
+  fi
+fi
 # End post install script
 echo 
\ No newline at end of file

--
Gitblit v1.10.0