August 17, 2008

Glassfish init script

Here's the init script for Glassfish. Change JAVA_HOME, GLASSFISH_HOME, USER variables for your environment.

#!/bin/sh
# This is for: Sun's J2EE sdk v5.05 (Glassfish)

JAVA_HOME=/usr/java6
GLASSFISH_HOME=/opt/glassfish
export JAVA_HOME

USER=glassfish
glassfish_stop() {
su $USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
}
glassfish_start() {
su $USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
}

case $1 in
start)
echo "Starting Glassfish server:"
glassfish_start
echo "."
;;
stop)
echo "Stopping Glassfish server:"
glassfish_stop
echo "."
;;
restart)
echo "Restarting Glassfish server:"
glassfish_stop
glassfish_start
echo "."
;;
*)
echo "Usage: /etc/init.d/glassfish start|stop|restart"
;;
esac

No comments:

Post a Comment