Skip to content

Instantly share code, notes, and snippets.

@malfario
Created May 6, 2012 11:05
Show Gist options
  • Save malfario/2621655 to your computer and use it in GitHub Desktop.
Save malfario/2621655 to your computer and use it in GitHub Desktop.
Glassfish init script
#! /bin/sh
### BEGIN INIT INFO
# Provides: glassfish
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Glassfish application server
# Description: Starts and stops glassfish application server domains
### END INIT INFO
# Author: Petri Laakso
#
# Do NOT "set -e"
# Glassfish installation directory
GLASSFISH=/opt/glassfish/
# List of domains to operate on
DOMAINS="domain1"
# Username to run application server
USER="glassfish"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Glassfish application server"
DAEMON=${GLASSFISH}/bin/asadmin
SCRIPTNAME="glassfish"
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
#
# Function that starts the daemon/service
#
do_start()
{
echo -n "Starting $DESC:"
for DOMAIN in $DOMAINS
do
echo -n " $DOMAIN"
su - $USER -c "$DAEMON start-domain $DOMAIN > /dev/null"
done
echo "."
}
#
# Function that stops the daemon/service
#
do_stop()
{
echo -n "Stopping $DESC:"
for DOMAIN in $DOMAINS
do
echo -n " $DOMAIN"
su - $USER -c "$DAEMON stop-domain $DOMAIN > /dev/null"
done
echo "."
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
restart|force-reload)
echo "Restarting $DESC"
do_stop
do_start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment