amsfo revision 0a99555401a033704f1f171baab6db11fb5528f2
1347N/A#!/bin/sh
1347N/A
1347N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1347N/A#
1347N/A# Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
1347N/A#
1347N/A# The contents of this file are subject to the terms
1347N/A# of the Common Development and Distribution License
1347N/A# (the License). You may not use this file except in
1347N/A# compliance with the License.
1347N/A#
1347N/A# You can obtain a copy of the License at
1347N/A# https://opensso.dev.java.net/public/CDDLv1.0.html or
1347N/A# opensso/legal/CDDLv1.0.txt
1347N/A# See the License for the specific language governing
1347N/A# permission and limitations under the License.
1347N/A#
1347N/A# When distributing Covered Code, include this CDDL
1347N/A# Header Notice in each file and include the License file
1347N/A# at opensso/legal/CDDLv1.0.txt.
1347N/A# If applicable, add the following below the CDDL Header,
1347N/A# with the fields enclosed by brackets [] replaced by
1347N/A# your own identifying information:
1347N/A# "Portions Copyrighted [year] [name of copyright owner]"
1347N/A#
1347N/A# $Id: amsfo,v 1.6 2009/04/16 15:35:58 subashvarma Exp $
1347N/A#
1347N/A#
1347N/A
1347N/A# Portions Copyrighted 2011 ForgeRock AS
1347N/A
1347N/ACONF_FILE=/opt/SUNWam/lib/amsfo.conf
1347N/ACONF_FILE_LINUX=/opt/sun/identity/lib/amsfo.conf
1347N/ACONF_FILE_HPUX=/opt/sun/identity/lib/amsfo.conf
1347N/A
1347N/A### To Debug this script set AMDEBUG to true ####
1347N/AAMDEBUG=false
1347N/A
1347N/AOS_ARCH=`/bin/uname -s`
1347N/A
1347N/Aif [ "$OS_ARCH" = "Linux" ]; then
1347N/A CONF_FILE=${CONF_FILE_LINUX}
1347N/Aelif [ "$OS_ARCH" = "HP-UX" ]; then
1347N/A CONF_FILE=${CONF_FILE_HPUX}
1347N/Afi
1347N/A
1347N/A##### sourceing amsfo config file ####
1347N/A. $CONF_FILE
1347N/A
1347N/AAM_BIN_DIR=$AM_HOME_DIR/bin
1347N/Aif [ "$OS_ARCH" = "Linux" ]; then
1347N/A AM_BIN_DIR=$AM_HOME_LINUX/bin
1347N/Aelif [ "$OS_ARCH" = "HP-UX" ]; then
1347N/A AM_BIN_DIR=$AM_HOME_HPUX/bin
1347N/Afi
1347N/AJMQ_BIN_DIR=/usr/bin
1347N/AJMQ_PID_FILE="$LOG_DIR/jmq.pid"
1347N/AAM_PID_FILE="$LOG_DIR/amdb.pid"
1347N/A
1347N/A#####hpux-dev#####
1347N/Aif [ "$OS_ARCH" = "Linux" ]; then
1347N/A JMQ_BIN_DIR=/opt/sun/mq/bin
1347N/Aelif [ "$OS_ARCH" = "HP-UX" ]; then
1347N/A JMQ_BIN_DIR=/opt/sun/mq/bin
1347N/Afi
1347N/A
1347N/AAMEXECUTABLE=$AM_BIN_DIR/amsessiondb
1347N/AJMQEXECUTABLE=$JMQ_BIN_DIR/imqbrokerd
1347N/A
1347N/ABROKER_OPTIONS="-silent"
1347N/A
1347N/Aif [ "$AMDEBUG" = "true" ]; then
1347N/A echo "restart $AM_SFO_RESTART"
1347N/A echo "cluster list $CLUSTER_LIST"
1347N/Afi
1347N/A
1347N/A
1347N/Astop_jmq() {
1347N/A if [ "$AMDEBUG" = "true" ] ; then
1347N/A echo "stopping JMQ Broker.."
1347N/A fi
1347N/A if test -f $JMQ_PID_FILE ; then
1347N/A kill -TERM `cat $JMQ_PID_FILE` >> /dev/null
1347N/A status=$?
1347N/A if [ "$AMDEBUG" = "true" ]; then
1347N/A if [ $status != 0 ]; then
1347N/A echo "Could not stop the JMQ Broker"
1347N/A else
1347N/A echo "JMQ Broker is shutdown"
1347N/A fi
1347N/A fi
1347N/A rm $JMQ_PID_FILE
1347N/A else
1347N/A if [ "$AMDEBUG" = "true" ]; then
1347N/A echo "JMQ Broker not running"
1347N/A fi
1347N/A exit 1
1347N/A fi
1347N/A
1347N/A}
1347N/A
1347N/A
1347N/Astart_jmq() {
1347N/A mkdir -p $LOG_DIR
1347N/A if [ "$AMDEBUG" = "true" ]; then
1347N/A echo "starting JMQ Broker"
1347N/A fi
1347N/A
1347N/A if [ $AM_SFO_RESTART = "true" ]; then
1347N/A BROKER_OPTIONS="-autorestart $BROKER_OPTIONS"
1347N/A fi
1347N/A
1347N/A _jmqpid=""
1347N/A
1347N/A if test -f $JMQ_PID_FILE ; then
1347N/A brok_pid=`cat $JMQ_PID_FILE`
1347N/A brok_status=`ps -e | grep $brok_pid`
1347N/A else
1347N/A brok_status=""
1347N/A fi
1347N/A
1347N/A if [ "$brok_status" != "" ]; then
1347N/A if [ "$AMDEBUG" = "true" ] ; then
1347N/A echo "JMQ Broker is already running."
1347N/A fi
1347N/A else
1347N/A if [ "$AMDEBUG" = "true" ]; then
1347N/A echo " $JMQEXECUTABLE -bgnd $BROKER_OPTIONS -vmargs $BROKER_VM_ARGS -name $BROKER_INSTANCE_NAME -port $BROKER_PORT -cluster $CLUSTER_LIST"
1347N/A fi
1347N/A
1347N/A $JMQEXECUTABLE -bgnd $BROKER_OPTIONS -vmargs "$BROKER_VM_ARGS" -name $BROKER_INSTANCE_NAME -port $BROKER_PORT -cluster $CLUSTER_LIST &
1347N/A _jmqpid=$!
1347N/A echo $_jmqpid > $JMQ_PID_FILE
1347N/A fi
1347N/A}
1347N/A
1347N/A
1347N/Astart_am() {
mkdir -p $LOG_DIR
export AM_SFO_RESTART
if [ "$AMDEBUG" = "true" ]; then
echo "starting amsessiondb client"
fi
# Check if the server is already running.
_amqpid=""
amdb_status=""
if test -f $AM_PID_FILE ; then
amdb_pid=`cat $AM_PID_FILE`
amdb_status=`ps -e | grep $amdb_pid`
else
amdb_status=""
fi
echo $amdb_status
if [ "$amdb_status" != "" ]; then
if [ "$AMDEBUG" = "true" ] ; then
echo "AM Session DB client is already running."
fi
else
if [ "$DELETE_DATABASE" = true ] ; then
rm -rf $DATABASE_DIR
fi
if [ "$AMDEBUG" = "true" ] ; then
echo "$AMEXECUTABLE -a $CLUSTER_LIST -u $USER_NAME -f $PASSWORDFILE -b $DATABASE_DIR $AMSESSIONDB_ARGS -m $CONF_FILE"
fi
mkdir -p $DATABASE_DIR
$AMEXECUTABLE -a $CLUSTER_LIST -u $USER_NAME -f $PASSWORDFILE -b $DATABASE_DIR $AMSESSIONDB_ARGS -m $CONF_FILE >> $LOG_DIR/amsessiondb.log &
_ampid=$!
echo $_ampid > $AM_PID_FILE
fi
}
stop_am() {
if [ "$AMDEBUG" = "true" ]; then
echo "stopping amsessiondb client."
fi
if test -f $AM_PID_FILE ; then
kill -TERM `cat $AM_PID_FILE`
status=$?
if [ "$AMDEBUG" = "true" ]; then
if [ $status != 0 ]; then
echo "Could not stop the amsessiondb client"
else
echo "amsessiondb is shutdown"
fi
fi
rm $AM_PID_FILE
else
if [ "$AMDEBUG" = "true" ]; then
echo "amsessiondb not running"
fi
fi
}
wait_jmq () {
_repeat=true
while [ $_repeat ]; do
EXIST=`netstat -an |grep $BROKER_PORT|grep LISTEN|wc -l`
if [ $EXIST -ge 1 ]; then
_repeat=
else
sleep 2
echo "\tWait for the broker to start properly"
fi
done
}
case "$1" in
'start')
if [ "$START_BROKER" = "true" ]; then
start_jmq
## Wait until the broker start up properly ##
wait_jmq
fi
start_am
;;
'stop')
stop_am
## Wait untill the AMDB shuts down properly ##
if [ "$START_BROKER" = "true" ]; then
sleep 5
stop_jmq
fi
;;
'start-jmq')
start_jmq
sleep 5
;;
'stop-jmq')
stop_jmq
sleep 5
;;
'start-amsdb')
start_am
sleep 5
;;
'stop-amsdb')
stop_am
sleep 5
;;
*)
echo "Usage: $0 { start | stop | start-jmq | stop-jmq | start-amsdb | stop-amsdb}"
;;
esac