postinstall.sh revision ff9ebc9ed4e9593360309eac406b1d021fa4d865
893N/A#!/bin/sh
2362N/A#
893N/A# CDDL HEADER START
893N/A#
893N/A# The contents of this file are subject to the terms of the
893N/A# Common Development and Distribution License, Version 1.0 only
893N/A# (the "License"). You may not use this file except in compliance
893N/A# with the License.
893N/A#
893N/A# You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
893N/A# or http://forgerock.org/license/CDDLv1.0.html.
893N/A# See the License for the specific language governing permissions
893N/A# and limitations under the License.
893N/A#
2362N/A# When distributing Covered Code, include this CDDL HEADER in each
893N/A# file and include the License file at
893N/A# legal-notices/CDDLv1_0.txt. If applicable,
893N/A# add the following below this CDDL HEADER, with the fields enclosed
893N/A# by brackets "[]" replaced with your own identifying information:
893N/A# Portions Copyright [yyyy] [name of copyright owner]
893N/A#
893N/A# CDDL HEADER END
893N/A#
893N/A# Copyright 2013-2015 ForgeRock AS.
893N/A
893N/A# ===============================
893N/A# RPM Post Install Script (%post)
893N/A# ===============================
893N/A
893N/A# The arguments to a %post are 1 and 2 for a new installation
893N/A# and upgrade, respectively. (%pre and %post aren't executed during
893N/A# an uninstallation.)
893N/A
893N/A# Registers the service
893N/A/sbin/chkconfig --add opendj
893N/A
893N/A# Symlinks to process ID
893N/Atest -h "/var/run/opendj.pid" || ln -s /opt/opendj/logs/server.pid /var/run/opendj.pid
893N/A
893N/Aif [ "$1" == "1" ] ; then
893N/A echo "Post Install - initial install"
893N/Aelse if [ "$1" == "2" ] ; then
893N/A echo "Post Install - upgrade install"
893N/A # Only if the instance has been configured
893N/A if [ -e "%{_prefix}"/config/buildinfo ] && [ "$(ls -A "%{_prefix}"/config/archived-configs)" ] ; then
893N/A "%{_prefix}"/./upgrade -n --acceptLicense
893N/A # If upgrade is ok, checks the server status flag for restart
893N/A if [ "$?" == "0" ] && [ -f "%{_prefix}"/logs/status ] ; then
893N/A echo ""
893N/A echo "Restarting server..."
893N/A "%{_prefix}"/./bin/start-ds
893N/A echo ""
893N/A rm -f "%{_prefix}"/logs/status
893N/A fi
893N/A
893N/A # Upgrade fails, needs user interaction (eg. manual mode)
893N/A if [ "$?" == "2" ] ; then
893N/A exit "0"
893N/A fi
893N/A else
893N/A echo "Instance is not configured. Upgrade aborted."
893N/A exit -1
893N/A fi
893N/A fi
893N/Afi
893N/A