#!/bin/bash
# chkconfig: 3331 80 20
# description: persistenceSession...
################################################################################
# startup(centos) persistenceSession.
#
# Copyright (c) 2008 masahito suzuki, Inc. All Rights Reserved.
################################################################################

# Source function library.
. /etc/rc.d/init.d/functions

# target directory.
EXECUTION_USER=
JAVA_HOME=
PSE_HOME=
TARGET_DIR=
PSE_START=${PSE_HOME}/sh/pse
PSE_END=${PSE_HOME}/sh/psed

pseStartup() {
    if [ -f ${PSE_START} ]; then
        echo "*** Starting persistenceSession[Server]"
        su - ${EXECUTION_USER} -c "export JAVA_HOME=${JAVA_HOME}; \
            export PSE_HOME=${PSE_HOME};\
            cd ${TARGET_DIR}; ${PSE_START} > /dev/null &"
    fi
}
pseShutdown() {
    if [ -f ${PSE_END} ]; then
        echo "*** Shutdown persistenceSession[Server]"
        su - ${EXECUTION_USER} -c "export JAVA_HOME=${JAVA_HOME}; \
            export PSE_HOME=${PSE_HOME};\
            cd ${TARGET_DIR}; ${PSE_END}"
    fi
}

case "$1" in
'start')
        pseStartup
        ;;
'stop')
        pseShutdown
        ;;

'restart')
        pseShutdown
        pseStartup
        ;;
*)
        echo "Usage: $0 {start stop restart}"
        ;;
esac
exit 0
