shutdown.sh revision 957d90fabed6f5fb1acb209d4804021b29b47b94
0N/A#!/bin/sh
0N/A
0N/AnotRunning() {
0N/A cleanupPidFile
0N/A echo "OpenIDM is not running, not stopping."
0N/A exit 1
0N/A}
0N/A
0N/AcleanupPidFile() {
0N/A # clean up left over pid files if necessary
0N/A if [ -f "$OPENIDM_PID_FILE" ]; then
0N/A rm -f "$OPENIDM_PID_FILE"
0N/A fi
0N/A}
0N/A
0N/A# resolve links - $0 may be a softlink
0N/APRG="$0"
0N/A
0N/Awhile [ -h "$PRG" ]; do
0N/A ls=`ls -ld "$PRG"`
0N/A link=`expr "$ls" : '.*-> \(.*\)$'`
0N/A if expr "$link" : '/.*' > /dev/null; then
0N/A PRG="$link"
0N/A else
0N/A PRG=`dirname "$PRG"`/"$link"
0N/A fi
0N/Adone
0N/A
0N/Aecho "$PRG"
0N/A
0N/A# Get standard environment variables
0N/APRGDIR=`dirname "$PRG"`
0N/A
# Only set OPENIDM_HOME if not already set
[ -z "$OPENIDM_HOME" ] && OPENIDM_HOME=`cd "$PRGDIR" >/dev/null; pwd`
# Only set OPENIDM_PID_FILE if not already set
[ -z "$OPENIDM_PID_FILE" ] && OPENIDM_PID_FILE="$OPENIDM_HOME"/.openidm.pid
if [ -f "$OPENIDM_PID_FILE" ]; then
START_PID=`cat "$OPENIDM_PID_FILE"`
fi
if [ -z "$START_PID" ]; then
notRunning
fi
EXISTING_START_RUNNING=`ps -p $START_PID -o command= | grep "./startup.sh"`
# Check if the pid file points to a running process that is the openidm jvm
if [ "$EXISTING_START_RUNNING" ]; then
echo "Stopping OpenIDM ($START_PID)"
pkill -P $START_PID
cleanupPidFile
exit 0
fi
# If the PID it points to is not the start script
# then it is a stale pid file
notRunning