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