286N/A#!/bin/bash
286N/Aset -e
286N/A# Post install script
286N/A# Install is launched with an empty second arg.
286N/A# If the package is already installed,
286N/A# the second arg. is not empty.
286N/A# Registers the service
286N/Aupdate-rc.d opendj defaults
286N/A# Symlinks to process ID
286N/Atest -h "/var/run/opendj.pid" || ln -s /opt/opendj/logs/server.pid /var/run/opendj.pid
286N/A# In this case, we are in upgrade mode.
286N/Aif [ "$1" = "configure" ] && [ ! -z "$2" ]
286N/Athen
286N/A# For being secure, we check the buildinfo file too.
286N/A if [ -f @prefix@/config/buildinfo ]
286N/A then
286N/A echo *Starting upgrade...
286N/A @prefix@/./upgrade -n --acceptLicense
286N/A echo
286N/A# Upgrade fails - Requires mandatory user interaction.
286N/A# Nevertheless, exits successfully of the pkg process.
286N/A if [ "$?" -eq 2 ]
286N/A then
286N/A exit 0
286N/A fi
286N/A# Restarts the service if needed.
286N/A# If server is stopped by upgrade process,
286N/A# the server will restart after upgrade.
286N/A# If server is stopped before the upgrade process
286N/A# (eg. upgrade the new package), the server will not restart.
286N/A# Uses the flag for determining server status at this point.
286N/A if [ "$?" -eq 0 ]
286N/A then
286N/A if [ -f @prefix@/logs/status ]
286N/A then
286N/A echo
286N/A echo "*Restarting server..."
286N/A @prefix@/./bin/start-ds
286N/A rm -f @prefix@/logs/status
286N/A fi
286N/A fi
286N/A else
286N/A# Invalid installation, could not find the buildinfo file.
286N/A echo "Invalid installation, could not find the build info file."
286N/A exit -1
286N/A fi
286N/Afi
286N/A# End post install script
286N/Aecho