Skip to content
Snippets Groups Projects
Commit 4ae54c35 authored by sveseli's avatar sveseli
Browse files

glassfish control script

parent 2bf4ea61
No related branches found
No related tags found
No related merge requests found
#! /bin/sh
### BEGIN INIT INFO
# Provides: glassfish
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts GlassFish
# Description: Starts GlassFish application server
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Set root to default if needed.
MY_DIR=`dirname $0` && cd $MY_DIR && MY_DIR=`pwd`
if [ -z "${DM_ROOT_DIR}" ]; then
DM_ROOT_DIR=$MY_DIR/../..
fi
# Source environment file.
DM_USER=`id -nu`
DM_HOST=`hostname -s`
DM_ENV_FILE=${DM_ROOT_DIR}/setup.sh
if [ ! -f ${DM_ENV_FILE} ]; then
echo "Environment file ${DM_ENV_FILE} does not exist."
exit 2
fi
. ${DM_ENV_FILE} > /dev/null
export AS_JAVA=$DM_SUPPORT_DIR/java/$DM_HOST_ARCH
DM_GLASSFISH_DIR=$DM_SUPPORT_DIR/glassfish/$DM_HOST_ARCH
DERBY_DIR=$DM_SUPPORT_DIR/glassfish/$DM_HOST_ARCH/javadb/bin
DM_DAEMON_NAME=glassfish
DM_DAEMON_CONTROL_CMD=$DM_GLASSFISH_DIR/bin/asadmin
DM_DAEMON_START_ARGS="start-domain domain1"
DM_DAEMON_STOP_ARGS="stop-domain domain1"
DM_DAEMON_STATUS_CMDS="uptime list-domains list-applications list-jdbc-resources"
start() {
echo -n $"Starting ${DM_DAEMON_NAME}: "
# Check if we're a privileged user
if [ `id -u` = 0 -a ${DM_USER} != "root" ]; then
su -m -c "${DM_DAEMON_CONTROL_CMD} ${DM_DAEMON_START_ARGS}" ${DM_USER}
else
${DM_DAEMON_CONTROL_CMD} ${DM_DAEMON_START_ARGS}
fi
RETVAL=$?
[ $RETVAL -eq 0 ] && success $"${DM_DAEMON_NAME} startup" || failure $"${DM_DAEMON_NAME} startup"
echo
}
stop() {
echo -n $"Stopping ${DM_DAEMON_NAME}: "
# Check if we're a privileged user
if [ `id -u` = 0 -a ${DM_USER} != "root" ]; then
su -m -c "${DM_DAEMON_CONTROL_CMD} ${DM_DAEMON_STOP_ARGS}" ${DM_USER}
else
${DM_DAEMON_CONTROL_CMD} ${DM_DAEMON_STOP_ARGS}
fi
RETVAL=$?
[ $RETVAL -eq 0 ] && success $"${DM_DAEMON_NAME} shutdown" || failure $"${DM_DAEMON_NAME} shutdown"
echo
}
status() {
# Check if we're a privileged user
if [ `id -u` = 0 -a ${DM_USER} != "root" ]; then
for cmd in ${DM_DAEMON_STATUS_CMDS}; do
su -m -c "${DM_DAEMON_CONTROL_CMD} ${cmd}" ${DM_USER}
done
else
for cmd in ${DM_DAEMON_STATUS_CMDS}; do
${DM_DAEMON_CONTROL_CMD} ${cmd}
done
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment