mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Violette Roche-Montane
16.14.2013 4571675a785cf27b01455331d41629d0aa0c4c6d
OPENDJ-904 RPM/Deb packages should not restart server after package update.
- Modified RPM/Deb scripts
- Modify RPM build number.
6 files modified
123 ■■■■ changed files
opends/build.xml 2 ●●● patch | view | raw | blame | history
opends/resource/debian/control/postinst 40 ●●●●● patch | view | raw | blame | history
opends/resource/debian/control/postrm 23 ●●●●● patch | view | raw | blame | history
opends/resource/debian/control/preinst 17 ●●●● patch | view | raw | blame | history
opends/resource/debian/control/prerm 13 ●●●● patch | view | raw | blame | history
opends/src/build-tools/org/opends/build/tools/GenerateRpm.java 28 ●●●● patch | view | raw | blame | history
opends/build.xml
@@ -1304,7 +1304,7 @@
    <getversionnumber property="VERSION_NUMBER_STRING" />
    <property name="prefix"    value="/opt/opendj"/>
    <property name="release"   value="2"/>
    <property name="release"   value="0"/>
    <taskdef name="genrpm"
             classname="org.opends.build.tools.GenerateRpm">
      <classpath>
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 
opends/resource/debian/control/postrm
@@ -1,20 +1,11 @@
#!/bin/bash
set -e
# POSTRM - Upgrade or remove script
if [ $1 == "remove" ] ; then
# Removing the remaining files
# Post rm script
# Files are removed automatically by pm.
if [ "$1" = "remove" ]
then
  echo
  echo *OpenDJ successfully removed
fi
if [ "$1" = "upgrade" ] ; then
  echo *Starting upgrade...
  @prefix@/./upgrade -n
# Upgrade ok, restarts the server.
  if [ "$?" -eq 0 ] ; then
    @prefix@/./bin/start-ds
  fi
# Upgrade fails - Needs user interaction
  if [ "$?" -eq 2 ] ; then
    exit 0
  fi
fi
echo
echo
# End of the post rm script
opends/resource/debian/control/preinst
@@ -1,6 +1,15 @@
#!/bin/sh
#!/bin/bash
set -e
# Pre installation section
# Insert your pre installation code here.
# Pre installation script
# If the server is running before upgrade, creates a flag.
if [ "$1" = "upgrade" ]
then
  if [ -f @prefix@/logs/server.pid ]
  then
    touch @prefix@/logs/status
  fi
  echo *Stopping OpenDJ server...
  @prefix@/bin/./stop-ds
fi
echo 
# End of the pre installation section
# End of the pre installation script
opends/resource/debian/control/prerm
@@ -1,9 +1,10 @@
#!/bin/sh
#!/bin/bash
set -e
# PRERM - Upgrade or remove script
if [ $1 = "upgrade" -o $1 = "remove" ] ; then
# Pre rm script
# Stops the server
if [ "$1" = "remove" ]
then
  echo *Stopping OpenDJ server...
  @prefix@/bin/stop-ds
  @prefix@/bin/./stop-ds
fi
echo
# End prem - upgrade or remove script
# End prem script
opends/src/build-tools/org/opends/build/tools/GenerateRpm.java
@@ -273,9 +273,14 @@
      sb.append("   echo \"Pre Install - initial install\"" + EOL);
      sb.append("else if [ \"$1\" == \"2\" ] ; then" + EOL);
      sb.append("   echo \"Pre Install - upgrade install\"" + EOL);
      sb.append("   %{_prefix}/bin/stop-ds" + EOL);
      sb.append("       echo \"\"" + EOL);
      sb.append("   fi" + EOL);
      sb.append("# If the server is running before upgrade, creates a file flag" + EOL);
      sb.append("           if [ -f %{_prefix}/logs/server.pid ] " + EOL);
      sb.append("           then" + EOL);
      sb.append("                   touch %{_prefix}/logs/status" + EOL);
      sb.append("           fi" + EOL);
      sb.append("       stopds=$(%{_prefix}/bin/stop-ds)" + EOL);
      sb.append("       echo $stopds" + EOL);
      sb.append("     fi" + EOL);
      sb.append("fi" + EOL);
      sb.append(EOL);
      sb.append("# Post Install" + EOL);
@@ -291,9 +296,17 @@
      // by rpm manager, which compares files between last & actual version.
      // Copies / deletes files depending of new package.
      sb.append("       %{_prefix}/./upgrade -n" + EOL);
      sb.append("# Upgrade ok, restarts the server" + EOL);
      sb.append("# Upgrade ok " + EOL);
      sb.append("         if [ \"$?\" == \"0\" ] ; then " + EOL);
      sb.append("           %{_prefix}/./bin/start-ds " + EOL);
      sb.append("# Checks the server status flag for restart. " + EOL);
      sb.append("             if [ -f %{_prefix}/logs/status ] " + EOL);
      sb.append("             then" + EOL);
      sb.append("                 echo \"\"" + EOL);
      sb.append("                 echo \"Restarting server...\" " + EOL);
      sb.append("                 %{_prefix}/./bin/start-ds " + EOL);
      sb.append("                 echo \"\"" + EOL);
      sb.append("                 rm -f %{_prefix}/logs/status " + EOL);
      sb.append("             fi" + EOL);
      sb.append("         fi" + EOL);
      sb.append("# Upgrade fails, needs user interaction (eg. manual mode)" + EOL);
      sb.append("         if [ \"$?\" == \"2\" ] ; then " + EOL);
@@ -397,7 +410,7 @@
  }
  /**
   * A file filter for the rpm. Excludes all '.bat' and '.app' files.
   * A file filter for the rpm. Excludes all '.bat', '.exe' and '.app' files.
   */
  static final class PkgFileFilter implements FileFilter
  {
@@ -413,7 +426,8 @@
      }
      else if (file.isFile())
      {
        if (fileName.endsWith(".app") || fileName.endsWith(".bat"))
        if (fileName.endsWith(".app") || fileName.endsWith(".bat")
            || fileName.endsWith(".exe"))
        {
          return false;
        }