Skip to content

Instantly share code, notes, and snippets.

@dazed19
Forked from maji-KY/glassfish
Last active November 2, 2018 08:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dazed19/7fd0d5259b9daf9b755a to your computer and use it in GitHub Desktop.
Save dazed19/7fd0d5259b9daf9b755a to your computer and use it in GitHub Desktop.
GlassFish Init Script
#!/bin/sh
#
# glassfish Startup script for glassfish
#
# chkconfig: - 99 01
# processname: glassfish
# config: /etc/glassfish/glassfish.conf
# config: /etc/sysconfig/glassfish
# pidfile: /var/run/glassfish.pid
# description: glassfish is a JavaEE Application Server
#
### BEGIN INIT INFO
# Provides: glassfish
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start:3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: start and stop glassfish
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/glassfish ]; then
. /etc/sysconfig/glassfish
fi
domain=domain1
prog=glassfish.${domain}
ASADMIN="/usr/local/glassfish/glassfish/bin/asadmin"
START_OP="start-domain"
STOP_OP="stop-domain"
DOMAIN_DIR="/usr/local/glassfish/glassfish/domains"
DOMAIN_ARGS="--domaindir ${DOMAIN_DIR} ${domain}"
lockfile=${LOCKFILE-/var/lock/subsys/${prog}}
pidfile=${PIDFILE-/var/run/${prog}.pid}
SLEEPMSEC=100000
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon --user glassfish --pidfile=${pidfile} ${ASADMIN} ${START_OP} ${DOMAIN_ARGS}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile} && cp ${DOMAIN_DIR}/${domain}/config/pid ${pidfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
${ASADMIN} ${STOP_OP} ${DOMAIN_ARGS}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
rh_status() {
status -p ${pidfile} ${prog}
}
# See how we were called.
case "$1" in
start)
rh_status >/dev/null 2>&1 && exit 0
start
;;
stop)
stop
;;
status)
rh_status
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart|status|help}"
RETVAL=2
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment