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

Violette Roche-Montane
27.23.2013 9af60f21a97a47394c0bb26d96f308d9c3ec73a1
OPENDJ-941 Package Upgrade: pre-install script should call stop-ds if the instance is not configured
4 files modified
33 ■■■■ changed files
opends/resource/debian/control/postinst 6 ●●●●● patch | view | raw | blame | history
opends/resource/debian/control/preinst 9 ●●●● patch | view | raw | blame | history
opends/resource/debian/control/prerm 3 ●●●● patch | view | raw | blame | history
opends/src/build-tools/org/opends/build/tools/GenerateRpm.java 15 ●●●●● patch | view | raw | blame | history
opends/resource/debian/control/postinst
@@ -14,12 +14,14 @@
    @prefix@/./upgrade -n
    echo
# Upgrade fails - Requires mandatory user interaction.
# Nevertheless, exits successfully of the pkg process.
    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.
# Restarts 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.
opends/resource/debian/control/preinst
@@ -1,15 +1,22 @@
#!/bin/bash
set -e
# Pre installation script
# If the server is running before upgrade, creates a flag.
if [ "$1" = "upgrade" ]
then
# Only if the instance has been configured
  if [ -f @prefix@/config/buildinfo ] && [ "$(ls -A @prefix@/config/archived-configs)" ]
  then
# If the server is running before upgrade, creates a flag.
  if [ -f @prefix@/logs/server.pid ]
  then
    touch @prefix@/logs/status
  fi
  echo *Stopping OpenDJ server...
  @prefix@/bin/./stop-ds
  else
    echo "Instance is not configured. Upgrade aborded."
    exit -1
  fi
fi
echo 
# End of the pre installation script
opends/resource/debian/control/prerm
@@ -2,7 +2,8 @@
set -e
# Pre rm script
# Stops the server
if [ "$1" = "remove" ]
# Only if the instance has been configured
if [ "$1" = "remove" ] && ( [ -f @prefix@/config/buildinfo ] && [ "$(ls -A @prefix@/config/archived-configs)" ] )
then
  echo *Stopping OpenDJ server...
  @prefix@/bin/./stop-ds
opends/src/build-tools/org/opends/build/tools/GenerateRpm.java
@@ -272,6 +272,9 @@
      sb.append("if [ \"$1\" == \"1\" ]; then" + EOL);
      sb.append("   echo \"Pre Install - initial install\"" + EOL);
      sb.append("else if [ \"$1\" == \"2\" ] ; then" + EOL);
      sb.append("# Only if the instance has been configured" + EOL);
      sb.append("    if [ -f %{_prefix}/config/buildinfo ] && [ \"$(ls -A %{_prefix}/config/archived-configs)\" ]" + EOL);
      sb.append("    then" + EOL);
      sb.append("   echo \"Pre Install - upgrade install\"" + EOL);
      sb.append("# If the server is running before upgrade, creates a file flag" + EOL);
      sb.append("           if [ -f %{_prefix}/logs/server.pid ] " + EOL);
@@ -282,6 +285,7 @@
      sb.append("       echo $stopds" + EOL);
      sb.append("     fi" + EOL);
      sb.append("fi" + EOL);
      sb.append("fi" + EOL);
      sb.append(EOL);
      sb.append("# Post Install" + EOL);
      sb.append("%post" + EOL);
@@ -292,6 +296,9 @@
      sb.append("       echo \"\"" + EOL);
      sb.append("else if [ \"$1\" == \"2\" ] ; then" + EOL);
      sb.append("   echo \"Post Install - upgrade install\"" + EOL);
      sb.append("# Only if the instance has been configured" + EOL);
      sb.append("    if [ -f %{_prefix}/config/buildinfo ] && [ \"$(ls -A %{_prefix}/config/archived-configs)\" ]" + EOL);
      sb.append("    then" + EOL);
      // Starts the upgrade. The new files are automatically imported
      // by rpm manager, which compares files between last & actual version.
      // Copies / deletes files depending of new package.
@@ -312,6 +319,10 @@
      sb.append("         if [ \"$?\" == \"2\" ] ; then " + EOL);
      sb.append("           exit \"0\" " + EOL);
      sb.append("         fi " + EOL);
      sb.append("    else" + EOL);
      sb.append("        echo \"Instance is not configured. Upgrade aborded.\"" + EOL);
      sb.append("        exit -1" + EOL);
      sb.append("    fi" + EOL);
      sb.append("   fi " + EOL);
      sb.append("fi" + EOL);
      sb.append(EOL);
@@ -327,7 +338,11 @@
      sb.append("%preun" + EOL);
      sb.append("if [ \"$1\" == \"0\" ] ; then" + EOL);
      sb.append("   echo \"Pre Uninstall - uninstall\"" + EOL);
      sb.append("# Only if the instance has been configured" + EOL);
      sb.append("    if [ -f %{_prefix}/config/buildinfo ] && [ \"$(ls -A %{_prefix}/config/archived-configs)\" ]" + EOL);
      sb.append("    then" + EOL);
      sb.append("   %{_prefix}/bin/stop-ds" + EOL);
      sb.append("    fi" + EOL);
      sb.append("else if [ \"$1\" == \"1\" ] ; then" + EOL);
      sb.append("   echo \"Pre Uninstall - upgrade uninstall\"" + EOL);
      sb.append("   fi" + EOL);