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

Violette Roche-Montane
22.38.2013 aedaf5652dd9b728942b9f30836458fe80a423c1
OPENDJ-1114 Improve the debian package
- Original data are copied under build/deb/ folder as the process to build the deb package implies to modify the source.
- Opendj init script has been modified. Indeed, under debian OS (and others) the /var/run/ folder is deleted at reboot, deleting by the same way our pid file, making the service wobbly.
- As linux distro use the same opendj file, a new folder was created under resource to store the shared file between them.
- At last, modified post/prem/specFile as well as the fact to create a symlink on an existing one throws an error. (same when you try to remove one from no-existing)
1 files added
4 files modified
220 ■■■■■ changed files
opends/build.xml 30 ●●●● patch | view | raw | blame | history
opends/resource/debian/control/postinst 4 ●●●● patch | view | raw | blame | history
opends/resource/debian/control/prerm 6 ●●●●● patch | view | raw | blame | history
opends/resource/rpm/specFile 9 ●●●●● patch | view | raw | blame | history
opends/resource/sysv/opendj 171 ●●●●● patch | view | raw | blame | history
opends/build.xml
@@ -1462,7 +1462,7 @@
    <copy file="resource/rpm/excludedFiles" tofile="${build.dir}/rpm/SOURCES/excludedFiles" />
    <replace file="${build.dir}/rpm/SOURCES/excludedFiles" token="# [[ excludedListFiles ]]" value="${excludedRPMFiles}" />
    
    <copy file="resource/rpm/opendj" tofile="${build.dir}/rpm/SOURCES/opendj" />
    <copy file="resource/sysv/opendj" tofile="${build.dir}/rpm/SOURCES/opendj" />
  
    <rpm specfile="specFile"
         topdir="${build.dir}/rpm"
@@ -1495,6 +1495,7 @@
    <property name="prefix"      value="/opt/opendj"/>
    <property name="release"     value="1"/>
    <property name="docprefix"   value="/usr/share/doc/opendj"/>
    <property name="build.deb.dir"   value="${build.dir}/deb/${SHORT_NAME}-${VERSION_NUMBER_STRING}"/>
    <mkdir dir="${build.dir}/deb/control" />
@@ -1511,32 +1512,33 @@
      </filterset>
    </copy>
    <!--        Debian files for preinst/postinstall/preuninstall/postuninstall -->
    <copy todir="${build.dir}/deb/control">
        <fileset dir="resource/debian/control"/>
    <copy todir="${build.deb.dir}">
        <fileset dir="${package.dir}/${SHORT_NAME}-${VERSION_NUMBER_STRING}"/>
    </copy>
    <copy file="resource/debian/copyright" tofile="${package.dir}/${SHORT_NAME}-${VERSION_NUMBER_STRING}/copyright" />
    <copy file="resource/debian/copyright" tofile="${build.deb.dir}/copyright" />
    <copy file="resource/sysv/opendj" tofile="${build.deb.dir}/opendj" />
    <replace dir="${build.dir}/deb/control/" token="@prefix@" value="${prefix}" />
    <deb destfile="${package.dir}/${PKG_NAME}_${pkg_version_string}-${release}${pkg_version_qualifier}_all.deb"
                  control="${build.dir}/deb/control" verbose="false">
      <tarfileset dir="${package.dir}/${SHORT_NAME}-${VERSION_NUMBER_STRING}"
      <tarfileset dir="${build.deb.dir}"
                  includes="**/*"
                  excludes="**/bat/**, **/*.app/**, **/*.bat*, **/*.exe*, bin/*, template/**/*, lib/*.sh, setup, uninstall, upgrade, legal-notices/**, copyright"
                  excludes="**/bat/**, **/*.app/**, **/*.bat*, **/*.exe*, bin/*, template/**/*, lib/*.sh, setup, uninstall, upgrade, legal-notices/**, copyright, README, bin/README_WINDOWS.txt, example-plugin.zip, opendj"
                  prefix="${prefix}" filemode="644" dirmode="755" />
      <tarfileset dir="${package.dir}/${SHORT_NAME}-${VERSION_NUMBER_STRING}" includes="lib/*.sh"
      <tarfileset dir="${build.deb.dir}" includes="lib/*.sh"
                  prefix="${prefix}" filemode="755" dirmode="755" />
      <tarfileset dir="${package.dir}/${SHORT_NAME}-${VERSION_NUMBER_STRING}" includes="bin/*"
      <tarfileset dir="${build.deb.dir}" includes="bin/*"
                  excludes="bin/README_WINDOWS.txt, **/bin/ControlPanel.app/"
                  prefix="${prefix}" filemode="755" dirmode="755" />
      <tarfileset dir="${package.dir}/${SHORT_NAME}-${VERSION_NUMBER_STRING}" includes="setup,uninstall,upgrade"
      <tarfileset dir="${build.deb.dir}" includes="setup,uninstall,upgrade"
                  prefix="${prefix}" filemode="755" dirmode="755" />
      <tarfileset dir="${package.dir}/${SHORT_NAME}-${VERSION_NUMBER_STRING}" includes="template/**/*"
      <tarfileset dir="${build.deb.dir}" includes="template/**/*"
                  prefix="${prefix}" filemode="444" dirmode="744" />      
      <tarfileset dir="${package.dir}/${SHORT_NAME}-${VERSION_NUMBER_STRING}" includes="legal-notices/**, copyright"
                  prefix="${docprefix}" filemode="755" dirmode="744" />
      <tarfileset dir="${build.deb.dir}" includes="legal-notices/**, copyright, README, example-plugin.zip"
                  prefix="${docprefix}" filemode="644" dirmode="755" />
      <tarfileset dir="${build.deb.dir}" includes="opendj"
                  prefix="/etc/init.d" filemode="755" dirmode="755" />
    </deb>
  </target>
opends/resource/debian/control/postinst
@@ -4,6 +4,10 @@
# Install is launched with an empty second arg.
# If the package is already installed, 
#  the second arg. is not empty.
# Registers the service
update-rc.d opendj defaults
# Symlinks to process ID
test -h "/var/run/opendj.pid" || ln -s /opt/opendj/logs/server.pid /var/run/opendj.pid
# In this case, we are in upgrade mode.
if [ "$1" = "configure" ] && [ ! -z "$2" ]
then
opends/resource/debian/control/prerm
@@ -1,6 +1,12 @@
#!/bin/bash
set -e
# Pre rm script
# Stops the service.
/etc/init.d/opendj stop >/dev/null 2>&1
# Deletes the service.
update-rc.d -f opendj remove
# Unlink the symlink to the process ID if it exists.
test -h "/var/run/opendj.pid" && unlink /var/run/opendj.pid
# Stops the server
# Only if the instance has been configured
if [ "$1" = "remove" ] && ( [ -f @prefix@/config/buildinfo ] && [ "$(ls -A @prefix@/config/archived-configs)" ] )
opends/resource/rpm/specFile
@@ -129,8 +129,8 @@
%post
# Registers the service
/sbin/chkconfig --add opendj
# Symlink to process ID
ln -s /opt/opendj/logs/server.pid /var/run/opendj.pid
# Symlinks to process ID
test -h "/var/run/opendj.pid" || ln -s /opt/opendj/logs/server.pid /var/run/opendj.pid
if [ "$1" == "1" ] ; then
    echo "Post Install - initial install"
else if [ "$1" == "2" ] ; then
@@ -177,7 +177,7 @@
    /etc/init.d/opendj stop >/dev/null 2>&1
    /sbin/chkconfig --del opendj
    # Unlink the symlink to the process ID.
    unlink /var/run/opendj.pid
    test -h "/var/run/opendj.pid" && unlink /var/run/opendj.pid
# Only if the instance has been configured    
    if [ -e "%{_prefix}"/config/buildinfo ] && [ "$(ls -A "%{_prefix}"/config/archived-configs)" ]
    then
@@ -221,3 +221,6 @@
- Added '%doc' section.
- Added '%changelog' at the end of the file.
- Added license to header's files.
* Thu Aug 22 2013 ForgeRock
- Modified init.d script.
opends/resource/sysv/opendj
New file
@@ -0,0 +1,171 @@
#! /bin/sh
#
# OPENDJ SERVICE SCRIPT
#
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License").  You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at
# trunk/opendj3/legal-notices/CDDLv1_0.txt
# or http://forgerock.org/license/CDDLv1.0.html.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at
# trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
# add the following below this CDDL HEADER, with the fields enclosed
# by brackets "[]" replaced with your own identifying information:
#      Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#      Copyright 2013 ForgeRock AS
#
# chkconfig: 2345 80 05
# description: Starts and stops opendj LDAPv3 service.
#
### BEGIN INIT INFO
# Provides:          opendj
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: This is the opendj daemon
# Description:       OpenDJ is an LDAPv3 compliant directory service, developed for the Java
#                    platform, providing a high performance, highly available and secure store
#                    for the identities managed by enterprises. Its easy installation process,
#                    combined with the power of the Java platform makes OpenDJ one of the
#                    simplest and fastest directory servers to deploy and manage.
### END INIT INFO
# Set up source function library depending on the distribution
if [ -f /etc/redhat-release ]
then
    # Redhat
    . /etc/init.d/functions
elif [ -f /etc/SuSE-release ]
then
    # SuSE
    . /etc/rc.status
elif [ -f /etc/lsb-release ]
then
    # Debian
    . /lib/lsb/init-functions
else
    # Other dist.
    if [ -f /etc/init.d/functions.sh ]
    then
        . /etc/init.d/functions.sh
    fi
fi
# Sets the script vars
INSTALL_ROOT="/opt/opendj/"
export INSTALL_ROOT
DAEMON=opendj
# Original PID file
ORIGINPIDFILE=/opt/opendj/logs/server.pid
# Pid file is a symlink to /opt/opendj/log/server.pid
PIDFILE=/var/run/opendj.pid
RETVAL=0
# If the daemon is not there, then exit / LSB return code.
test -x "$INSTALL_ROOT/bin/start-ds" || exit 5
# /var/run is deleted after reboot (eg. debian)
# recreates the symlink if needed.
test -h "$PIDFILE" || ln -s $ORIGINPIDFILE $PIDFILE
#Starts the server and creates pid file.
start() {
    echo -n $"Starting $DAEMON: "
    # Server is running
    if [ -e $PIDFILE ]
    then
        echo "> Already running."
        return 0
    else
        "$INSTALL_ROOT"/bin/start-ds --quiet
        RETVAL=$?
        if [ $RETVAL = 0 ]
        then
            echo "> SUCCESS."
        else
            echo "> FAILURE."
        fi
        echo ""
        return $RETVAL
    fi
}
#Stops the server and removes pid file.
stop() {
    echo -n $"Stopping $DAEMON: "
    # Server is running
    if [ -e $PIDFILE ]
    then
        "$INSTALL_ROOT"/bin/stop-ds --quiet
        RETVAL=$?
        if [ $RETVAL = 0 ]
        then
            echo "> SUCCESS."
        else
            echo "> FAILURE."
        fi
        echo ""
        return $RETVAL
    else
        echo "> Already stopped."
        echo ""
        return 3
    fi
}
# Displays the service status
status() {
    echo -n $"$DAEMON status: "
    if [ -e $PIDFILE ]
    then
        echo "> Running."
        return 0
    else
        echo "> Stopped."
        return 3
    fi
}
case "$1" in
    start)
        start
    ;;
    stop)
        stop
    ;;
    restart)
        stop
        sleep 5
        start
    ;;
    force-reload)
        # Not implemented.
    ;;
    status)
        status
    ;;
    *)
        echo $"Usage: /etc/init.d/$DAEMON {start|restart|stop|force-reload|status}"
        exit 1
    ;;
esac
exit $RETVAL