Sunday, September 29, 2013

SysV Script - GlassFish for RHEL Server


Just one more sysV script to manage GlassFish as service daemon :

https://github.com/sp4wnr0ot/util-scripts/blob/master/glassfish-rhel-sysV
-----


#!/bin/bash
###################################################
# Init file for GlassFish Server Daemon / Applicable for Red Hat Cluster Suite
# chkconfig: 2345 73 29
# Author: Raul da Silva Leite
# e-mail: sp4wn.root@gmail.com
# description: glassfish-cluster-svs
#

##################################################
IFACE_LISTEN="bond.254"
IP_INFO=$(ifconfig $IFACE_LISTEN | grep 'inet addr' | cut -d":" -f2 | sed 's/Bcast//g')

start() {
CONNECT_HTTP=$(nc -w1 $IP_INFO 8080 &>/dev/null; echo $?)
CONNECT_SIP=$(nc -w1 $IP_INFO 5060 &>/dev/null; echo $?)

    if [ $CONNECT_HTTP -eq 0 ] && [ $CONNECT_SIP -eq 0 ] ; then
        echo -ne "Sun GlassFish Communications Server running\n"
    else
        echo -ne "Starting Sun GlassFish Communications Server.\n"
        /home/nextel/java/sailfin/bin/asadmin start-domain domain1
    return 0
    fi
}

##################################################

stop() {
CONNECT_HTTP=$(nc -w1 $IP_INFO 8080 &>/dev/null; echo $?)
CONNECT_SIP=$(nc -w1 $IP_INFO 5060 &>/dev/null; echo $?)

        if [ $CONNECT_HTTP -eq 0 ] || [ $CONNECT_SIP -eq 0 ] ; then
            echo -ne "Shutting down Sun GlassFish Communications Server.\n"
            /home/nextel/java/sailfin/bin/asadmin stop-domain
        return 0
        else
            echo -ne "Sun GlassFish Communications Server is not runnig\n"
        return 0
        fi
}

##################################################
status() {
CONNECT_HTTP=$(nc -w1 $IP_INFO 8080 &>/dev/null; echo $?)
CONNECT_SIP=$(nc -w1 $IP_INFO 5060 &>/dev/null; echo $?)

        if [ $CONNECT_HTTP -eq 0 ] && [ $CONNECT_SIP -eq 0 ] ; then
            echo -ne "Sun GlassFish Communications Server running\n"
        return 0
        else
            echo -ne "Sun GlassFish Communications Server is not running\n"
        return 1
        fi
}

##################################################
 

case "$1" in
start)
start
;;
stop)
stop
;;


##################################################
********************
Reference : 
https://github.com/sp4wnr0ot/util-scripts/blob/master/glassfish-rhel-sysV

No comments:

Post a Comment