17th
AUG

Glassfish init script

Posted by Keith under J2EE, Java

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

[sourcecode language=’css’]
#!/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
[/sourcecode]

Trackback URL for this post: http://blog.keithkim.com/2008/08/glassfish-init-script/trackback/

Reader's Comments

  1. Stan Towianski |

    Your ” double quotes are somehow different characters. Maybe the first/left quote in these lines like for: -c “$GLA

    I was getting a run permission error so I went and changed them all manually to a ”
    They don’t really look different but the editor color changes and it works.

  2. Keith |

    Thanks for pointing that out. I think this blog s/w changed the quote when I copy&pasted the script. I need to figure out how I can have section in this blog+theme to resolve that. Sorry for the confusion.

Leave a Reply